2017-04-05 20:56:22 +00:00
|
|
|
//==============================================================================
|
|
|
|
// This file is part of Master Password.
|
|
|
|
// Copyright (c) 2011-2017, Maarten Billemont.
|
2013-04-30 01:15:14 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// Master Password is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2013-04-30 01:15:14 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// Master Password is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
2013-04-30 01:15:14 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// You can find a copy of the GNU General Public License in the
|
|
|
|
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
|
|
|
//==============================================================================
|
2013-04-30 01:15:14 +00:00
|
|
|
|
|
|
|
#import "MPLogsViewController.h"
|
|
|
|
#import "MPiOSAppDelegate.h"
|
2013-05-12 18:08:45 +00:00
|
|
|
#import "MPAppDelegate_Store.h"
|
2013-04-30 01:15:14 +00:00
|
|
|
|
2014-09-15 05:00:23 +00:00
|
|
|
@implementation MPLogsViewController
|
2013-08-11 19:30:01 +00:00
|
|
|
|
2013-04-30 01:15:14 +00:00
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
2014-04-20 15:09:49 +00:00
|
|
|
self.view.backgroundColor = [UIColor clearColor];
|
2013-04-30 01:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
2014-09-27 05:27:05 +00:00
|
|
|
PearlAddNotificationObserver( NSUserDefaultsDidChangeNotification, nil, [NSOperationQueue mainQueue],
|
|
|
|
^(MPLogsViewController *self, NSNotification *note) {
|
|
|
|
self.levelControl.selectedSegmentIndex = [[MPiOSConfig get].traceMode boolValue]? 1: 0;
|
|
|
|
} );
|
|
|
|
|
2014-04-20 15:09:49 +00:00
|
|
|
self.logView.contentInset = UIEdgeInsetsMake( 64, 0, 93, 0 );
|
|
|
|
|
2013-04-30 01:15:14 +00:00
|
|
|
[self refresh:nil];
|
|
|
|
|
|
|
|
self.levelControl.selectedSegmentIndex = [[MPiOSConfig get].traceMode boolValue]? 1: 0;
|
|
|
|
}
|
|
|
|
|
2014-09-27 05:27:05 +00:00
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
|
|
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
|
|
|
|
PearlRemoveNotificationObservers();
|
|
|
|
}
|
|
|
|
|
2013-04-30 01:15:14 +00:00
|
|
|
- (IBAction)toggleLevelControl:(UISegmentedControl *)sender {
|
|
|
|
|
|
|
|
BOOL traceEnabled = (BOOL)self.levelControl.selectedSegmentIndex;
|
|
|
|
if (traceEnabled) {
|
|
|
|
[PearlAlert showAlertWithTitle:@"Enable Trace Mode?" message:
|
2014-09-27 05:27:05 +00:00
|
|
|
@"Trace mode will log the internal operation of the application.\n"
|
|
|
|
@"Unless you're looking for the cause of a problem, you should leave this off to save memory."
|
2013-04-30 01:15:14 +00:00
|
|
|
viewStyle:UIAlertViewStyleDefault initAlert:nil
|
|
|
|
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
|
|
|
if (buttonIndex == [alert cancelButtonIndex])
|
|
|
|
return;
|
|
|
|
|
|
|
|
[MPiOSConfig get].traceMode = @YES;
|
2013-10-31 03:37:12 +00:00
|
|
|
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Enable Trace", nil];
|
2013-04-30 01:15:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
[MPiOSConfig get].traceMode = @NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)refresh:(UIBarButtonItem *)sender {
|
|
|
|
|
|
|
|
self.logView.text = [[PearlLogger get] formatMessagesWithLevel:PearlLogLevelTrace];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)mail:(UIBarButtonItem *)sender {
|
|
|
|
|
2013-04-30 05:49:53 +00:00
|
|
|
if ([[MPiOSConfig get].traceMode boolValue]) {
|
|
|
|
[PearlAlert showAlertWithTitle:@"Hiding Trace Messages" message:
|
2014-09-27 05:27:05 +00:00
|
|
|
@"Trace-level log messages will not be mailed. "
|
|
|
|
@"These messages contain sensitive and personal information."
|
2013-04-30 05:49:53 +00:00
|
|
|
viewStyle:UIAlertViewStyleDefault initAlert:nil
|
|
|
|
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
|
|
|
[[MPiOSAppDelegate get] openFeedbackWithLogs:YES forVC:self];
|
2013-10-31 03:37:12 +00:00
|
|
|
} cancelTitle:[PearlStrings get].commonButtonOkay otherTitles:nil];
|
2013-04-30 05:49:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
[[MPiOSAppDelegate get] openFeedbackWithLogs:YES forVC:self];
|
2013-04-30 01:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|