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) {
|
2020-01-14 18:59:32 +00:00
|
|
|
UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Enable Trace Mode?" message:
|
|
|
|
@"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."
|
|
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
[controller addAction:[UIAlertAction actionWithTitle:@"Enable Trace" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
[MPiOSConfig get].traceMode = @YES;
|
|
|
|
}]];
|
|
|
|
[controller addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
|
|
|
|
[self presentViewController:controller animated:YES completion: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]) {
|
2020-01-14 18:59:32 +00:00
|
|
|
UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Hiding Trace Messages" message:
|
|
|
|
@"Trace-level log messages will not be mailed. "
|
|
|
|
@"These messages contain sensitive and personal information."
|
|
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
[controller addAction:[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
[[MPiOSAppDelegate get] openFeedbackWithLogs:YES forVC:self];
|
|
|
|
}]];
|
|
|
|
[self presentViewController:controller animated:YES completion: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
|