-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGrowLViewAppDelegate.m
119 lines (108 loc) · 3.63 KB
/
GrowLViewAppDelegate.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
//
// GrowLViewAppDelegate.m
// GrowLView
//
// Created by Faye Pearson on 14/01/2011.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "GrowLViewAppDelegate.h"
#import "LVMenuItem.h"
#import "NSMutableData+endian.h"
@implementation GrowLViewAppDelegate
@synthesize window;
@synthesize textView;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSString *PngPath;
PngPath = [[NSBundle mainBundle] pathForResource:@"mail" ofType:@"png"];
mailPng = [[[NSData alloc] initWithContentsOfFile:PngPath] autorelease];
liveView = [[LiveView alloc] init];
[liveView registerWithCallback:self];
[liveView addMenuItem:[LVMenuItem itemWithTitle:@"Mail" unread:1 image:mailPng isAlert:TRUE delegate:self]];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
[liveView stop];
[liveView release];
[mailPng release];
}
- (void)newLiveViewConnection {
[textView insertText:[NSString stringWithFormat:@"New connection from version %@!\n",[liveView softwareVersion]]];
}
- (void)handleLiveViewAlertAction:(int)alertActionParam atItem:(int)menuItemParam;
{
switch (alertActionParam) {
case kAlertFirst:
[textView insertText:[NSString stringWithFormat:@"First from item %d\n",menuItemParam]];
break;
case kAlertPrev:
[textView insertText:[NSString stringWithFormat:@"Prev from item %d\n",menuItemParam]];
break;
case kAlertNext:
[textView insertText:[NSString stringWithFormat:@"Next from item %d\n",menuItemParam]];
break;
case kAlertLast:
[textView insertText:[NSString stringWithFormat:@"Last from item %d\n",menuItemParam]];
break;
case kAlertCurrent:
[textView insertText:[NSString stringWithFormat:@"Current from item %d\n",menuItemParam]];
break;
default:
[textView insertText:[NSString stringWithFormat:@"Unknown from item %d\n",menuItemParam]];
break;
}
}
- (void)handleLiveViewNavigationAction:(int)navActionParam ofType:(int)navTypeParam
inMenu:(int)menuIdParam atItem:(int)menuItemParam {
switch (navActionParam) {
case kActionPress:
[textView insertText: @"Pressed "];
break;
case kActionDoublePress:
[textView insertText: @"Double-pressed "];
break;
case kActionLongPress:
[textView insertText: @"Held "];
break;
default:
break;
}
switch (navTypeParam) {
case kNavUp:
[textView insertText:[NSString stringWithFormat:@"Up on menu %d at item %d\n",menuIdParam,menuItemParam]];
break;
case kNavDown:
[textView insertText:[NSString stringWithFormat:@"Down on menu %d at item %d\n",menuIdParam,menuItemParam]];
break;
case kNavLeft:
[textView insertText:[NSString stringWithFormat:@"Left on menu %d at item %d\n",menuIdParam,menuItemParam]];
break;
case kNavRight:
[textView insertText:[NSString stringWithFormat:@"Right on menu %d at item %d\n",menuIdParam,menuItemParam]];
break;
case kNavSelect:
[textView insertText:[NSString stringWithFormat:@"Select on menu %d at item %d\n",menuIdParam,menuItemParam]];
break;
case kNavMenuSelect:
[textView insertText:[NSString stringWithFormat:@"MenuSelect on menu %d at item %d\n",menuIdParam,menuItemParam]];
break;
default:
[textView insertText:[NSString stringWithFormat:@"Unknown on menu %d at item %d\n",menuIdParam,menuItemParam]];
break;
}
}
- (void)handleLiveViewDeviceStatus:(int)status {
switch (status) {
case kDeviceStatusOff:
[textView insertText:@"Screen powered off\n"];
break;
case kDeviceStatusOn:
[textView insertText:@"Screen powered on\n"];
break;
case kDeviceStatusMenu:
[textView insertText:@"Screen in menu mode\n"];
break;
default:
[textView insertText:@"Device state unknown\n"];
break;
}
}
@end