-
Notifications
You must be signed in to change notification settings - Fork 2
/
GPGRemoteKey extensions.m
76 lines (58 loc) · 2.05 KB
/
GPGRemoteKey extensions.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
//
// GPGKey extensions.m
// ABKeyManager
//
// Created by Robert Goldsmith on 06/02/2005.
// Copyright 2005 Far-Blue. All rights reserved.
//
#import "GPGRemoteKey extensions.h"
#import "NSDate extensions.h"
#import "ABKeyManagerPluginBundleResourceAccess.h"
extern int ABSystemVersion;
@implementation GPGRemoteKey (AB_gui_extensions)
-(NSString *)statusDescription
{
if([self isKeyRevoked])
return KeyManagerLocalizedString(@"Revoked",@"GPGKey Status");
if([self hasKeyExpired])
return KeyManagerLocalizedString(@"Expired",@"GPGKey Status");
return @"";
}
-(NSString *)uidCount
{return [NSString stringWithFormat:@"%i",[[self userIDs] count]];}
-(NSString *)formattedCreationDate
{
if(![self creationDate])
return nil;
if(ABSystemVersion<8)
{
CFDateFormatterRef aFormatter = CFDateFormatterCreate(NULL, NULL, kCFDateFormatterMediumStyle, kCFDateFormatterNoStyle);
NSString *dateFormat = [NSDate calendarFormatFromICUDateFormat:(NSString *)CFDateFormatterGetFormat(aFormatter)];
CFRelease(aFormatter);
return [[self creationDate] descriptionWithCalendarFormat:dateFormat];
}
return [[self creationDate] descriptionWithCalendarFormat:@"%x" locale:[NSLocale currentLocale]];
}
-(NSString *)formattedExpirationDate
{
if(![self expirationDate])
return nil;
if(ABSystemVersion<8)
{
CFDateFormatterRef aFormatter = CFDateFormatterCreate(NULL, NULL, kCFDateFormatterMediumStyle, kCFDateFormatterNoStyle);
NSString *dateFormat = [NSDate calendarFormatFromICUDateFormat:(NSString *)CFDateFormatterGetFormat(aFormatter)];
CFRelease(aFormatter);
return [[self expirationDate] descriptionWithCalendarFormat:dateFormat];
}
return [[self expirationDate] descriptionWithCalendarFormat:@"%x" locale:[NSLocale currentLocale]];
}
-(NSString *)formattedShortKeyID
{return [NSString stringWithFormat:@"0x%@",[self shortKeyID]];}
//Bindings stuff
//*********************************************************
-(id)valueForUndefinedKey:(NSString *)key
{
NSLog(@"GPGRemoteKey: Could not bind '%@'",key);
return [NSNumber numberWithInt:0];
}
@end