/
MessagesAction.m
90 lines (67 loc) · 1.68 KB
/
MessagesAction.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
//
// MessagesAction.m
// ControlPlane
//
// Created by Dustin Rue on 6/23/12.
//
//
#import "MessagesAction.h"
#import "Messages.h"
#import "DSLogger.h"
@implementation MessagesAction
- (id)init
{
if (!(self = [super init]))
return nil;
status = [[NSString alloc] init];
return self;
}
- (id)initWithDictionary:(NSDictionary *)dict
{
if (!(self = [super initWithDictionary:dict]))
return nil;
status = [[dict valueForKey:@"parameter"] copy];
return self;
}
- (void)dealloc
{
[status release];
[super dealloc];
}
- (NSMutableDictionary *)dictionary
{
NSMutableDictionary *dict = [super dictionary];
[dict setObject:[[status copy] autorelease] forKey:@"parameter"];
return dict;
}
- (NSString *)description
{
return [NSString stringWithFormat:NSLocalizedString(@"Setting Messages/iChat status to '%@'.", @""), status];
}
- (BOOL) execute: (NSString **) errorString {
@try {
MessagesApplication *Messages = [SBApplication applicationWithBundleIdentifier: @"com.apple.iChat"];
// set status message
Messages.statusMessage = status;
} @catch (NSException *e) {
DSLog(@"Exception: %@", e);
*errorString = NSLocalizedString(@"Couldn't set Messages/iChat status!", @"In MessagesAction");
return NO;
}
return YES;
}
+ (NSString *)helpText
{
return NSLocalizedString(@"The parameter for Messages/iChat actions is the status message to set.", @"");
}
+ (NSString *)creationHelpText
{
return NSLocalizedString(@"Set Messages/iChat status message to", @"");
}
+ (NSString *) friendlyName {
return NSLocalizedString(@"Messages/iChat Status", @"");
}
+ (NSString *)menuCategory {
return NSLocalizedString(@"Application", @"");
}
@end