Permalink
Browse files

Add SMART report.

  • Loading branch information...
etresoft committed Oct 26, 2016
1 parent dd08cdc commit b9187cd281fc5fa1124396c8b531741bc73a774c
@@ -76,6 +76,8 @@
A5C292F219A13D0800464E86 /* HardwareCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = A5C292F119A13D0800464E86 /* HardwareCollector.m */; };
A5C292F519A2214E00464E86 /* VideoCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = A5C292F419A2214E00464E86 /* VideoCollector.m */; };
A5C292F819A2220400464E86 /* SystemSoftwareCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = A5C292F719A2220400464E86 /* SystemSoftwareCollector.m */; };
A5C9E07D1DBDCA670099288B /* SMARTManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A5C9E07C1DBDCA670099288B /* SMARTManager.m */; };
A5C9E0811DBDD1DA0099288B /* smartctl in CopyFiles */ = {isa = PBXBuildFile; fileRef = A5C9E0801DBDD1DA0099288B /* smartctl */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
A5C9FC041A1AADA200C1EAA5 /* LogCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = A5C9FC031A1AADA200C1EAA5 /* LogCollector.m */; };
A5CC608F19B4BF9E006D7E94 /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A55BC1AF15C0901800D42EF1 /* ServiceManagement.framework */; };
A5CF26E81A279DAD002386F0 /* AdwareCollector.m in Sources */ = {isa = PBXBuildFile; fileRef = A5CF26E71A279DAD002386F0 /* AdwareCollector.m */; };
@@ -103,6 +105,19 @@
F7B1FDB21D82A8860027E122 /* SearchEngine.m in Sources */ = {isa = PBXBuildFile; fileRef = F7B1FDB11D82A8860027E122 /* SearchEngine.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
A5C9E07F1DBDD1C10099288B /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 7;
files = (
A5C9E0811DBDD1DA0099288B /* smartctl in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
A50C9DAB19A2ACB600BA6A25 /* StartupItemsCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StartupItemsCollector.h; sourceTree = "<group>"; };
A50C9DAC19A2ACB600BA6A25 /* StartupItemsCollector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StartupItemsCollector.m; sourceTree = "<group>"; };
@@ -246,6 +261,9 @@
A5C292F419A2214E00464E86 /* VideoCollector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideoCollector.m; sourceTree = "<group>"; };
A5C292F619A2220400464E86 /* SystemSoftwareCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemSoftwareCollector.h; sourceTree = "<group>"; };
A5C292F719A2220400464E86 /* SystemSoftwareCollector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SystemSoftwareCollector.m; sourceTree = "<group>"; };
A5C9E07B1DBDCA670099288B /* SMARTManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SMARTManager.h; sourceTree = "<group>"; };
A5C9E07C1DBDCA670099288B /* SMARTManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SMARTManager.m; sourceTree = "<group>"; };
A5C9E0801DBDD1DA0099288B /* smartctl */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = smartctl; path = ../smartctl; sourceTree = "<group>"; };
A5C9FC021A1AADA200C1EAA5 /* LogCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogCollector.h; sourceTree = "<group>"; };
A5C9FC031A1AADA200C1EAA5 /* LogCollector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LogCollector.m; sourceTree = "<group>"; };
A5CC608C19B4BF52006D7E94 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
@@ -340,6 +358,8 @@
A54B87341A1D4F1900F25213 /* HelpManager.m */,
A54B87361A1D4FED00F25213 /* DetailManager.h */,
A54B87371A1D4FED00F25213 /* DetailManager.m */,
A5C9E07B1DBDCA670099288B /* SMARTManager.h */,
A5C9E07C1DBDCA670099288B /* SMARTManager.m */,
A5221BCB1C6188E6009AF9F8 /* UninstallManager.h */,
A5221BCA1C6188E6009AF9F8 /* UninstallManager.m */,
A5CF26E91A27FB21002386F0 /* AdwareManager.h */,
@@ -555,6 +575,7 @@
A51BD14B1A7D7782000AAABA /* adwarehelp.rtf */,
A5716E0D1C4C41BB00297727 /* unknownhelp.rtf */,
A546BFB91A5348880032C354 /* linkhelp.rtf */,
A5C9E0801DBDD1DA0099288B /* smartctl */,
);
name = "Supporting Files";
sourceTree = "<group>";
@@ -579,6 +600,7 @@
A55BC16615BF987D00D42EF1 /* Frameworks */,
A54DA58D1A314C8C00F09B19 /* ShellScript */,
A55BC16715BF987D00D42EF1 /* Resources */,
A5C9E07F1DBDD1C10099288B /* CopyFiles */,
);
buildRules = (
);
@@ -691,6 +713,7 @@
A55BC18115BF987D00D42EF1 /* AppDelegate.m in Sources */,
A5FC11F419A4C00F00E81E9C /* ITunesPlugInsCollector.m in Sources */,
A5C292E019A02B2700464E86 /* Collector.m in Sources */,
A5C9E07D1DBDCA670099288B /* SMARTManager.m in Sources */,
A5C292EC19A039D900464E86 /* LaunchDaemonsCollector.m in Sources */,
A5221BCC1C6188E6009AF9F8 /* UninstallManager.m in Sources */,
A50C9DBF19A36CC400BA6A25 /* GatekeeperCollector.m in Sources */,
View
@@ -8,6 +8,7 @@
@class SlideshowView;
@class DetailManager;
@class SMARTManager;
@class HelpManager;
@class AdwareManager;
@class UnknownFilesManager;
@@ -80,6 +81,7 @@
NSMutableSet * appleLaunchd;
DetailManager * myDetailManager;
SMARTManager * mySMARTManager;
HelpManager * myHelpManager;
AdwareManager * myAdwareManager;
UnknownFilesManager * myUnknownFilesManager;
@@ -154,6 +156,7 @@
@property (retain) IBOutlet NSImage * donateButtonInactiveImage;
@property (retain) IBOutlet NSToolbar * toolbar;
@property (retain) IBOutlet DetailManager * detailManager;
@property (retain) IBOutlet SMARTManager * smartManager;
@property (retain) IBOutlet HelpManager * helpManager;
@property (retain) IBOutlet AdwareManager * adwareManager;
@property (retain) IBOutlet UnknownFilesManager * unknownFilesManager;
View
@@ -21,6 +21,7 @@
#import "NSAttributedString+Etresoft.h"
#import "NSDictionary+Etresoft.h"
#import "DetailManager.h"
#import "SMARTManager.h"
#import "HelpManager.h"
#import "EtreCheckToolbarItem.h"
#import "AdwareManager.h"
@@ -103,6 +104,7 @@ @implementation AppDelegate
@synthesize donateButtonInactiveImage = myDonateButtonInactiveImage;
@synthesize toolbar = myToolbar;
@synthesize detailManager = myDetailManager;
@synthesize smartManager = mySMARTManager;
@synthesize helpManager = myHelpManager;
@synthesize adwareManager = myAdwareManager;
@synthesize unknownFilesManager = myUnknownFilesManager;
@@ -553,6 +555,8 @@ - (void) handleGetURLEvent: (NSAppleEventDescriptor *) event
[self.adwareManager show];
else if([manager isEqualToString: @"unknownfiles"])
[self.unknownFilesManager show];
else if([manager isEqualToString: @"smart"])
[self.smartManager showDetail: [[url path] substringFromIndex: 1]];
}
}
@@ -1883,6 +1887,7 @@ - (void) askForDonation
// Handle a scroll change in the report view.
- (void) didScroll: (NSNotification *) notification
{
[self.smartManager closeDetail: self];
[self.detailManager closeDetail: self];
[self.helpManager closeDetail: self];
}
@@ -1892,6 +1897,7 @@ - (void) drawerWillOpen: (NSNotification *) notification
{
NSDrawer * drawer = [notification object];
[self.smartManager closeDrawerIfNotDrawer: drawer];
[self.detailManager closeDrawerIfNotDrawer: drawer];
[self.helpManager closeDrawerIfNotDrawer: drawer];
}
View
@@ -316,6 +316,28 @@ - (void) collectSMARTStatus: (NSDictionary *) disk
[NSDictionary
dictionaryWithObjectsAndKeys:
[NSColor redColor], NSForegroundColorAttributeName, nil]];
NSString * device = [disk objectForKey: @"bsd_name"];
NSMutableAttributedString * urlString =
[[NSMutableAttributedString alloc] initWithString: @""];
[urlString
appendString:
[NSString stringWithFormat:
NSLocalizedString(@"%@[Show SMART report]", NULL), indent]
attributes:
@{
NSFontAttributeName : [[Utilities shared] boldFont],
NSForegroundColorAttributeName : [[Utilities shared] blue],
NSLinkAttributeName :
[NSString stringWithFormat: @"etrecheck://smart/%@", device]
}];
[self.result appendAttributedString: urlString];
[self.result appendString: @"\n"];
[urlString release];
}
// Print information about a Core Storage volume.
View
@@ -0,0 +1,12 @@
/***********************************************************************
** Etresoft
** John Daniel
** Copyright (c) 2016. All rights reserved.
**********************************************************************/
#import <Foundation/Foundation.h>
#import "PopoverManager.h"
@interface SMARTManager : PopoverManager
@end
View
@@ -0,0 +1,100 @@
/***********************************************************************
** Etresoft
** John Daniel
** Copyright (c) 2016. All rights reserved.
**********************************************************************/
#import "SMARTManager.h"
#import "Model.h"
#import "DiagnosticEvent.h"
#import "SubProcess.h"
@interface PopoverManager ()
// Show detail.
- (void) showDetail: (NSString *) title
content: (NSAttributedString *) content;
@end
@implementation SMARTManager
// Show detail.
- (void) showDetail: (NSString *) name
{
NSString * smartctlPath =
[[NSBundle mainBundle] pathForResource: @"smartctl" ofType: nil];
NSArray * args =
@[
name,
@"-a"
];
SubProcess * subProcess = [[SubProcess alloc] init];
if([subProcess execute: smartctlPath arguments: args])
{
NSString * title =
[NSString
stringWithFormat:
NSLocalizedString(@"SMART report for device %@", NULL), name];
NSString * contentString =
[[NSString alloc]
initWithData: subProcess.standardOutput
encoding: NSUTF8StringEncoding];
NSAttributedString * content =
[[NSAttributedString alloc] initWithString: contentString];
[super showDetail: title content: content];
[self.textView
setFont: [NSFont fontWithName: @"Courier" size: 10]
range: NSMakeRange(0, [self.details length])];
[content release];
[contentString release];
}
[subProcess release];
}
// Resize the detail pane to match the content.
- (void) resizeDetail: (NSTextStorage *) storage
{
NSSize minWidth = self.minDrawerSize;
if(self.popover)
minWidth = self.minPopoverSize;
NSSize size = [self.popover contentSize];
size.width = 645;
size.height = 420;
NSRect textViewFrame = [self.textView frame];
textViewFrame.size.width = size.width - 45;
textViewFrame.size.height = size.height - 20;
[self.textView setFrame: textViewFrame];
if(self.popover)
{
if(size.height < self.minPopoverSize.height)
size.height = self.minPopoverSize.height;
[self.popover setContentSize: size];
}
else
{
if(size.height < self.minPopoverSize.height)
size.height = self.minPopoverSize.height;
[self.drawer setContentSize: size];
}
}
@end
@@ -53,6 +53,7 @@
<outlet property="reportView" destination="Rah-Ot-abL" id="9Oc-0g-Xed"/>
<outlet property="shareButton" destination="eGD-du-9Qv" id="jI4-wr-wpU"/>
<outlet property="shareToolbarItemView" destination="Wry-qn-NGq" id="k9F-9h-KBJ"/>
<outlet property="smartManager" destination="EFo-xp-MVA" id="c61-Ag-xTX"/>
<outlet property="spinner" destination="Udp-hz-whF" id="9PX-SM-esE"/>
<outlet property="startPanel" destination="hni-3i-hk1" id="fxa-bP-QVp"/>
<outlet property="startPanelAnimationView" destination="PhF-uw-q0W" id="sqN-ro-ubL"/>
@@ -90,6 +91,29 @@
<outlet property="view" destination="TdQ-Ra-PPP" id="78X-xz-HJb"/>
</connections>
</viewController>
<customObject id="EFo-xp-MVA" userLabel="SMART Manager" customClass="SMARTManager">
<connections>
<outlet property="contentView" destination="LrJ-81-PLR" id="bw4-k4-wxh"/>
<outlet property="drawer" destination="4W0-xu-mhf" id="UHF-Ku-JYA"/>
<outlet property="popoverViewController" destination="Snk-cw-Amx" id="ErA-1w-nUq"/>
<outlet property="textView" destination="A3B-Ay-068" id="1Q4-eo-nNR"/>
<outlet property="title" destination="GWI-bP-aAN" id="raD-QF-UqB"/>
</connections>
</customObject>
<drawer trailingOffset="15" id="4W0-xu-mhf" userLabel="SMART Drawer">
<size key="contentSize" width="100" height="100"/>
<size key="maxContentSize" width="10000" height="10000"/>
<connections>
<outlet property="contentView" destination="S2I-p7-4EW" id="OGo-6c-tdJ"/>
<outlet property="delegate" destination="Voe-Tx-rLC" id="Kgd-Oo-d8F"/>
<outlet property="parentWindow" destination="HCb-1A-LX1" id="Ym8-CN-HlD"/>
</connections>
</drawer>
<viewController id="Snk-cw-Amx" userLabel="SMART Popover View Controller">
<connections>
<outlet property="view" destination="S2I-p7-4EW" id="Lpd-1l-yt3"/>
</connections>
</viewController>
<customObject id="OAP-T5-MR2" userLabel="Help Manager" customClass="HelpManager">
<connections>
<outlet property="contentView" destination="LrJ-81-PLR" id="WeX-ob-JLZ"/>
@@ -1164,6 +1188,64 @@ Gw
</subviews>
<point key="canvasLocation" x="-200.5" y="-23.5"/>
</customView>
<customView id="S2I-p7-4EW" userLabel="SMART View">
<rect key="frame" x="0.0" y="0.0" width="241" height="261"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="aoy-Xi-Ddc">
<rect key="frame" x="1" y="45" width="240" height="181"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" id="RsR-Sk-SLC">
<rect key="frame" x="1" y="1" width="238" height="179"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView editable="NO" importsGraphics="NO" richText="NO" findStyle="panel" verticallyResizable="YES" spellingCorrection="YES" id="A3B-Ay-068">
<rect key="frame" x="0.0" y="0.0" width="238" height="179"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="238" height="179"/>
<size key="maxSize" width="463" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="238" height="179"/>
<size key="maxSize" width="463" height="10000000"/>
</textView>
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="mIQ-nG-Nwx">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="7NF-zO-liR">
<rect key="frame" x="224" y="1" width="15" height="133"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<accessibility description="Detail contents"/>
</scrollView>
<button verticalHuggingPriority="750" id="WsY-1i-hra">
<rect key="frame" x="82" y="5" width="76" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="push" title="Close" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="eeF-n5-CAq">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<accessibility description="Close the detail window"/>
<connections>
<action selector="closeDetail:" target="EFo-xp-MVA" id="95m-8B-tdc"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="GWI-bP-aAN">
<rect key="frame" x="18" y="234" width="205" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Label" id="7zT-A9-FtT">
<font key="font" metaFont="systemBold"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<point key="canvasLocation" x="-4.5" y="176.5"/>
</customView>
<customView id="nCU-Ry-DLu" userLabel="Help View">
<rect key="frame" x="0.0" y="0.0" width="241" height="261"/>
<autoresizingMask key="autoresizingMask"/>
Oops, something went wrong.

0 comments on commit b9187cd

Please sign in to comment.