2005-06-02 18:16:43 +00:00
|
|
|
//
|
|
|
|
// FeedbackController.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Vincent Spader on 3/26/05.
|
2005-07-02 21:02:06 +00:00
|
|
|
// Copyright 2005 Vincent Spader All rights reserved.
|
2005-06-02 18:16:43 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "FeedbackController.h"
|
|
|
|
|
2013-10-11 12:03:55 +00:00
|
|
|
#import "Logging.h"
|
2005-06-02 18:16:43 +00:00
|
|
|
|
|
|
|
@implementation FeedbackController
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (id)init {
|
2009-03-07 23:08:43 +00:00
|
|
|
return [super initWithWindowNibName:@"Feedback"];
|
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (IBAction)showWindow:(id)sender {
|
2005-06-02 18:16:43 +00:00
|
|
|
[fromView setStringValue:@""];
|
|
|
|
[subjectView setStringValue:@""];
|
|
|
|
[messageView setString:@""];
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2009-03-07 23:08:43 +00:00
|
|
|
[super showWindow:sender];
|
2005-06-02 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)alertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo {
|
|
|
|
if([(NSNumber *)CFBridgingRelease(contextInfo) boolValue] == YES) {
|
2009-03-07 23:08:43 +00:00
|
|
|
[[self window] close];
|
2005-06-05 18:52:35 +00:00
|
|
|
}
|
2005-06-02 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)feedbackDidNotSend:(FeedbackSocket *)feedback {
|
2013-10-11 12:03:55 +00:00
|
|
|
ALog(@"Error sending feedback");
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2005-06-02 18:16:43 +00:00
|
|
|
[sendingIndicator stopAnimation:self];
|
|
|
|
|
2016-05-05 20:05:39 +00:00
|
|
|
NSAlert *alert = [[NSAlert alloc] init];
|
2005-07-11 20:22:53 +00:00
|
|
|
[alert setMessageText:NSLocalizedString(@"FeedbackFailedMessageText", @"")];
|
|
|
|
[alert setInformativeText:NSLocalizedString(@"FeedbackFailedInformativeText", @"")];
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2016-05-05 20:05:39 +00:00
|
|
|
[alert beginSheetModalForWindow:[self window] modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:(void *)CFBridgingRetain([NSNumber numberWithBool:NO])];
|
2005-06-02 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (void)feedbackDidSend:(FeedbackSocket *)feedback {
|
2005-06-02 18:16:43 +00:00
|
|
|
[sendingIndicator stopAnimation:self];
|
|
|
|
|
2016-05-05 20:05:39 +00:00
|
|
|
NSAlert *alert = [[NSAlert alloc] init];
|
2005-07-11 20:22:53 +00:00
|
|
|
[alert setMessageText:NSLocalizedString(@"FeedbackSuccessMessageText", @"")];
|
|
|
|
[alert setInformativeText:NSLocalizedString(@"FeedbackSuccessInformativeText", @"")];
|
2005-06-02 18:16:43 +00:00
|
|
|
|
2016-05-05 20:05:39 +00:00
|
|
|
[alert beginSheetModalForWindow:[self window] modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:(void *)CFBridgingRetain([NSNumber numberWithBool:YES])];
|
2005-06-02 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (IBAction)sendFeedback:(id)sender {
|
2005-06-02 18:16:43 +00:00
|
|
|
[sendingIndicator startAnimation:self];
|
2022-02-07 05:49:27 +00:00
|
|
|
|
|
|
|
// Using this so that if its a bad connection, it doesnt sit there looking stupid..or should it
|
2005-06-02 18:16:43 +00:00
|
|
|
feedbackSocket = [[FeedbackSocket alloc] init];
|
|
|
|
[feedbackSocket setDelegate:self];
|
2007-05-27 15:34:04 +00:00
|
|
|
|
|
|
|
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
|
2022-02-07 05:49:27 +00:00
|
|
|
|
2007-05-27 15:34:04 +00:00
|
|
|
[feedbackSocket sendFeedback:[fromView stringValue] subject:[subjectView stringValue] message:[messageView string] version:version];
|
2005-06-02 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
2022-02-07 05:49:27 +00:00
|
|
|
- (IBAction)cancel:(id)sender {
|
2009-03-07 23:08:43 +00:00
|
|
|
[[self window] close];
|
2005-06-02 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|