2010-01-06 18:11:16 -06:00
|
|
|
//
|
|
|
|
// MGMBugWindow.m
|
|
|
|
// GeckoReporter
|
|
|
|
//
|
|
|
|
// Created by Mr. Gecko on 1/2/10.
|
2011-08-30 15:02:29 -05:00
|
|
|
// Copyright (c) 2011 Mr. Gecko's Media (James Coleman). http://mrgeckosmedia.com/
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
|
|
// with or without fee is hereby granted, provided that the above copyright notice
|
|
|
|
// and this permission notice appear in all copies.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
|
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
// FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
|
|
|
|
// OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
// DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
|
|
// ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2010-01-06 18:11:16 -06:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "MGMBugWindow.h"
|
|
|
|
#import "MGMReporter.h"
|
|
|
|
#import "MGMSender.h"
|
|
|
|
#import "MGMLocalized.h"
|
2010-06-03 19:41:31 -05:00
|
|
|
#import "MGMSystemInfo.h"
|
2010-01-06 18:11:16 -06:00
|
|
|
#import "MGMLog.h"
|
|
|
|
|
|
|
|
@implementation MGMBugWindow
|
2010-01-12 08:05:09 -06:00
|
|
|
+ (id)sharedBugWindow {
|
2010-01-06 18:11:16 -06:00
|
|
|
return [[self alloc] init];
|
|
|
|
}
|
|
|
|
- (id)init {
|
2011-08-30 15:02:29 -05:00
|
|
|
if ((self = [super init])) {
|
2010-01-06 18:11:16 -06:00
|
|
|
if (![NSBundle loadNibNamed:@"MGMBugWindow" owner:self]) {
|
|
|
|
[self release];
|
|
|
|
self = nil;
|
|
|
|
} else {
|
|
|
|
NSUserDefaults *userDefautls = [NSUserDefaults standardUserDefaults];
|
|
|
|
if ([userDefautls objectForKey:MGMGRUserEmail])
|
|
|
|
[userEmailField setStringValue:[userDefautls objectForKey:MGMGRUserEmail]];
|
|
|
|
|
|
|
|
[mainWindow makeKeyAndOrderFront:self];
|
2010-08-12 12:00:31 -05:00
|
|
|
MGMSystemInfo *sysInfo = [MGMSystemInfo info];
|
2010-05-05 17:09:21 -05:00
|
|
|
if ([sysInfo isUIElement])
|
|
|
|
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
2010-01-06 18:11:16 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc {
|
|
|
|
MGMLog(@"%s Releasing", __PRETTY_FUNCTION__);
|
2011-08-30 15:02:29 -05:00
|
|
|
[mailSender release];
|
|
|
|
[mainWindow release];
|
2010-01-06 18:11:16 -06:00
|
|
|
[super dealloc];
|
|
|
|
self = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setButtonsEnabled:(BOOL)flag {
|
|
|
|
[sendButton setEnabled:flag];
|
|
|
|
[cancelButton setEnabled:flag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)close {
|
|
|
|
[mainWindow orderOut:self];
|
|
|
|
[self release];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)send:(id)sender {
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:[userEmailField stringValue] forKey:MGMGRUserEmail];
|
|
|
|
if (mailSender==nil) {
|
2010-01-12 08:05:09 -06:00
|
|
|
mailSender = [MGMSender new];
|
2010-01-06 18:11:16 -06:00
|
|
|
[mailSender sendBug:[[bugView textStorage] string] reproduce:[[reproduceView textStorage] string] delegate:self];
|
|
|
|
}
|
|
|
|
[sendButton setTitle:MGMLocalized(@"Sending...", nil)];
|
|
|
|
[self setButtonsEnabled:NO];
|
|
|
|
}
|
|
|
|
- (IBAction)cancel:(id)sender {
|
|
|
|
[self close];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)sendError:(NSError *)error {
|
|
|
|
NSAlert *theAlert = [[NSAlert new] autorelease];
|
|
|
|
[theAlert addButtonWithTitle:MGMLocalized(@"Ok", nil)];
|
|
|
|
[theAlert setMessageText:MGMLocalized(@"Error could not send bug report.", nil)];
|
|
|
|
[theAlert setInformativeText:[error localizedDescription]];
|
|
|
|
[theAlert setAlertStyle:2];
|
|
|
|
[theAlert runModal];
|
|
|
|
[self setButtonsEnabled:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)sendFinished:(NSString *)received {
|
|
|
|
MGMLog(@"%@", received);
|
|
|
|
[self close];
|
|
|
|
}
|
|
|
|
@end
|