From 0586a69bc0bd43bceb592a644d4aea3c4f8f40a6 Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Sun, 22 Jul 2012 00:32:42 +0200 Subject: [PATCH] Clean up some private ivars and methods and move them into their own header files --- Classes/BITCrashManager.h | 5 -- Classes/BITCrashManager.m | 1 + Classes/BITCrashManagerPrivate.h | 41 +++++++++ Classes/BITHockeyManager.m | 4 +- Classes/BITUpdateManager.h | 56 +----------- Classes/BITUpdateManager.m | 26 +----- Classes/BITUpdateManagerPrivate.h | 99 +++++++++++++++++++++ Classes/BITUpdateViewController.m | 2 + Support/HockeySDK.xcodeproj/project.pbxproj | 8 ++ 9 files changed, 156 insertions(+), 86 deletions(-) create mode 100644 Classes/BITCrashManagerPrivate.h create mode 100644 Classes/BITUpdateManagerPrivate.h diff --git a/Classes/BITCrashManager.h b/Classes/BITCrashManager.h index 3b57cca868..6bb9598c6d 100644 --- a/Classes/BITCrashManager.h +++ b/Classes/BITCrashManager.h @@ -55,7 +55,6 @@ typedef enum BITCrashStatus { NSString *_feedbackRequestID; float _feedbackDelayInterval; - NSMutableString *_contentOfProperty; BITCrashStatus _serverResult; int _analyzerStarted; @@ -109,8 +108,4 @@ typedef enum BITCrashStatus { // will return the timeinterval from startup to the crash in seconds, default is -1 @property (nonatomic, readonly) NSTimeInterval timeintervalCrashInLastSessionOccured; -- (id)initWithAppIdentifier:(NSString *)appIdentifier; - -- (void)startManager; - @end diff --git a/Classes/BITCrashManager.m b/Classes/BITCrashManager.m index 0837146b1c..34fdb37c40 100644 --- a/Classes/BITCrashManager.m +++ b/Classes/BITCrashManager.m @@ -34,6 +34,7 @@ #import "HockeySDK.h" #import "HockeySDKPrivate.h" +#import "BITCrashManagerPrivate.h" #import "BITCrashReportTextFormatter.h" #include diff --git a/Classes/BITCrashManagerPrivate.h b/Classes/BITCrashManagerPrivate.h new file mode 100644 index 0000000000..3dcd8e9b02 --- /dev/null +++ b/Classes/BITCrashManagerPrivate.h @@ -0,0 +1,41 @@ +/* + * Author: Andreas Linde + * Kent Sutherland + * + * Copyright (c) 2012 HockeyApp, Bit Stadium GmbH. + * Copyright (c) 2011 Andreas Linde & Kent Sutherland. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#import + + +@interface BITCrashManager () { +} + +- (id)initWithAppIdentifier:(NSString *)appIdentifier; + +- (void)startManager; + +@end diff --git a/Classes/BITHockeyManager.m b/Classes/BITHockeyManager.m index 36ad5eb529..ae1bf584dd 100644 --- a/Classes/BITHockeyManager.m +++ b/Classes/BITHockeyManager.m @@ -29,7 +29,9 @@ #import "HockeySDK.h" #import "HockeySDKPrivate.h" -#import "BITUpdateManager.h" + +#import "BITCrashManagerPrivate.h" +#import "BITUpdateManagerPrivate.h" @interface BITHockeyManager () diff --git a/Classes/BITUpdateManager.h b/Classes/BITUpdateManager.h index 1c1469ee53..0ac1f7cc45 100644 --- a/Classes/BITUpdateManager.h +++ b/Classes/BITUpdateManager.h @@ -55,6 +55,7 @@ typedef enum { @class BITUpdateViewController; @interface BITUpdateManager : NSObject { +@private NSString *_appIdentifier; NSString *_currentAppVersion; @@ -63,7 +64,6 @@ typedef enum { BOOL _dataFound; BOOL _showFeedback; - BOOL _updateURLOffline; BOOL _updateAlertShowing; BOOL _lastCheckFailed; @@ -136,61 +136,7 @@ typedef enum { // default value: HockeyUpdateCheckStartup @property (nonatomic, assign) BITUpdateSetting updateSetting; -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Private Properties - -// if YES, the API will return an existing JMC config -// if NO, the API will return only version information -@property (nonatomic, assign) BOOL checkForTracker; - -// Contains the tracker config if received from server -@property (nonatomic, retain, readonly) NSDictionary *trackerConfig; - - -- (id)initWithAppIdentifier:(NSString *)appIdentifier isAppStoreEnvironemt:(BOOL)isAppStoreEnvironment; - -- (void)startManager; - -// is an update available? -- (BOOL)isUpdateAvailable; - -// are we currently checking for updates? -- (BOOL)isCheckInProgress; - -// open update info view -- (void)showUpdateView; - -// manually start an update check -- (void)checkForUpdate; - -// checks for update, informs the user (error, no update found, etc) -- (void)checkForUpdateShowFeedback:(BOOL)feedback; - -// initiates app-download call. displays an system UIAlertView -- (BOOL)initiateAppDownload; - -// checks wether this app version is authorized -- (BOOL)appVersionIsAuthorized; - -// start checking for an authorization key -- (void)checkForAuthorization; - // convenience methode to create hockey view controller - (BITUpdateViewController *)hockeyViewController:(BOOL)modal; -// get/set current active hockey view controller -@property (nonatomic, retain) BITUpdateViewController *currentHockeyViewController; - -// convenience method to get current running version string -- (NSString *)currentAppVersion; - -// get newest app version -- (BITAppVersionMetaInfo *)newestAppVersion; - -// get array of all available versions -- (NSArray *)appVersions; - -// check if there is any newer version mandatory -- (BOOL)hasNewerMandatoryVersion; - @end diff --git a/Classes/BITUpdateManager.m b/Classes/BITUpdateManager.m index 608cc6f23b..2415c8aee1 100644 --- a/Classes/BITUpdateManager.m +++ b/Classes/BITUpdateManager.m @@ -34,7 +34,7 @@ #import "HockeySDK.h" #import "HockeySDKPrivate.h" -#import "BITUpdateManager.h" +#import "BITUpdateManagerPrivate.h" #import "BITAppVersionMetaInfo.h" #import "NSString+BITHockeyAdditions.h" @@ -51,30 +51,6 @@ #define BETA_UPDATE_TIMESTAMP @"timestamp" #define BETA_UPDATE_APPSIZE @"appsize" -@interface BITUpdateManager () -- (id)parseJSONResultString:(NSString *)jsonString; -- (BOOL)shouldCheckForUpdates; -- (void)startUsage; -- (void)stopUsage; -- (void)showAuthorizationScreen:(NSString *)message image:(NSString *)image; -- (BOOL)canSendUserData; -- (BOOL)canSendUsageTime; -- (NSString *)currentUsageString; -- (NSString *)installationDateString; -- (NSString *)authenticationToken; -- (BITUpdateAuthorizationState)authorizationState; - -@property (nonatomic, assign, getter=isUpdateAvailable) BOOL updateAvailable; -@property (nonatomic, assign, getter=isCheckInProgress) BOOL checkInProgress; -@property (nonatomic, retain) NSMutableData *receivedData; -@property (nonatomic, copy) NSDate *lastCheck; -@property (nonatomic, copy) NSArray *appVersions; -@property (nonatomic, retain) NSURLConnection *urlConnection; -@property (nonatomic, copy) NSDate *usageStartTimestamp; -@property (nonatomic, retain) UIView *authorizeView; -@property (nonatomic, retain) NSDictionary *trackerConfig; -@end - @implementation BITUpdateManager diff --git a/Classes/BITUpdateManagerPrivate.h b/Classes/BITUpdateManagerPrivate.h new file mode 100644 index 0000000000..5d6b71f9ad --- /dev/null +++ b/Classes/BITUpdateManagerPrivate.h @@ -0,0 +1,99 @@ +/* + * Author: Andreas Linde + * Peter Steinberger + * + * Copyright (c) 2012 HockeyApp, Bit Stadium GmbH. + * Copyright (c) 2011 Andreas Linde. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + + +#import + + +@interface BITUpdateManager () { +} + +// is an update available? +@property (nonatomic, assign, getter=isUpdateAvailable) BOOL updateAvailable; + +// are we currently checking for updates? +@property (nonatomic, assign, getter=isCheckInProgress) BOOL checkInProgress; + +@property (nonatomic, retain) NSMutableData *receivedData; + +@property (nonatomic, copy) NSDate *lastCheck; + +// get array of all available versions +@property (nonatomic, copy) NSArray *appVersions; + +@property (nonatomic, retain) NSURLConnection *urlConnection; + +@property (nonatomic, copy) NSDate *usageStartTimestamp; + +@property (nonatomic, retain) UIView *authorizeView; + +// if YES, the API will return an existing JMC config +// if NO, the API will return only version information +@property (nonatomic, assign) BOOL checkForTracker; + +// Contains the tracker config if received from server +@property (nonatomic, retain) NSDictionary *trackerConfig; + + +- (id)initWithAppIdentifier:(NSString *)appIdentifier isAppStoreEnvironemt:(BOOL)isAppStoreEnvironment; + +- (void)startManager; + +// open update info view +- (void)showUpdateView; + +// manually start an update check +- (void)checkForUpdate; + +// checks for update, informs the user (error, no update found, etc) +- (void)checkForUpdateShowFeedback:(BOOL)feedback; + +// initiates app-download call. displays an system UIAlertView +- (BOOL)initiateAppDownload; + +// checks wether this app version is authorized +- (BOOL)appVersionIsAuthorized; + +// start checking for an authorization key +- (void)checkForAuthorization; + +// get/set current active hockey view controller +@property (nonatomic, retain) BITUpdateViewController *currentHockeyViewController; + +// convenience method to get current running version string +- (NSString *)currentAppVersion; + +// get newest app version +- (BITAppVersionMetaInfo *)newestAppVersion; + +// check if there is any newer version mandatory +- (BOOL)hasNewerMandatoryVersion; + +@end diff --git a/Classes/BITUpdateViewController.m b/Classes/BITUpdateViewController.m index 799ca54b11..62ab8a0a63 100644 --- a/Classes/BITUpdateViewController.m +++ b/Classes/BITUpdateViewController.m @@ -40,6 +40,8 @@ #import "HockeySDK.h" #import "HockeySDKPrivate.h" +#import "BITUpdateManagerPrivate.h" + #define BIT_RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1] #define kWebCellIdentifier @"PSWebTableViewCell" diff --git a/Support/HockeySDK.xcodeproj/project.pbxproj b/Support/HockeySDK.xcodeproj/project.pbxproj index 512f4ca791..6f963527e2 100644 --- a/Support/HockeySDK.xcodeproj/project.pbxproj +++ b/Support/HockeySDK.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 1E01118115BB6311007002AC /* BITUpdateManagerPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E01118015BB62FE007002AC /* BITUpdateManagerPrivate.h */; }; + 1E01118215BB6314007002AC /* BITCrashManagerPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E01117E15BB6228007002AC /* BITCrashManagerPrivate.h */; }; 1E27EF2515BB5033000AE995 /* HockeySDK.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1E59555F15B6F80E00A03429 /* HockeySDK.strings */; }; 1E40BCB515A3487500BD64D9 /* BITCrashManagerDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E40BCB415A3487500BD64D9 /* BITCrashManagerDelegate.h */; settings = {ATTRIBUTES = (); }; }; 1E40BCB915A3494400BD64D9 /* BITCrashReportTextFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E40BCB715A3494400BD64D9 /* BITCrashReportTextFormatter.h */; }; @@ -168,6 +170,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 1E01117E15BB6228007002AC /* BITCrashManagerPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BITCrashManagerPrivate.h; sourceTree = ""; }; + 1E01118015BB62FE007002AC /* BITUpdateManagerPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BITUpdateManagerPrivate.h; sourceTree = ""; }; 1E40BCB415A3487500BD64D9 /* BITCrashManagerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BITCrashManagerDelegate.h; sourceTree = ""; }; 1E40BCB715A3494400BD64D9 /* BITCrashReportTextFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BITCrashReportTextFormatter.h; sourceTree = ""; }; 1E40BCB815A3494400BD64D9 /* BITCrashReportTextFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BITCrashReportTextFormatter.m; sourceTree = ""; }; @@ -354,6 +358,7 @@ E41EB459148D7BF50015DEDC /* BITAppVersionMetaInfo.h */, E41EB45A148D7BF50015DEDC /* BITAppVersionMetaInfo.m */, E41EB45D148D7BF50015DEDC /* BITUpdateManager.h */, + 1E01118015BB62FE007002AC /* BITUpdateManagerPrivate.h */, 1E5955D515B72ED500A03429 /* BITUpdateManager.m */, 1E5955EE15B7752200A03429 /* BITUpdateManagerDelegate.h */, 1E5955E215B751ED00A03429 /* BITUpdateViewController.h */, @@ -361,6 +366,7 @@ E41EB45F148D7BF50015DEDC /* BITUpdateSettingsViewController.h */, E41EB460148D7BF50015DEDC /* BITUpdateSettingsViewController.m */, 1E5955D115B72E5300A03429 /* BITCrashManager.h */, + 1E01117E15BB6228007002AC /* BITCrashManagerPrivate.h */, E41EB464148D7BF50015DEDC /* BITCrashManager.m */, 1E40BCB415A3487500BD64D9 /* BITCrashManagerDelegate.h */, 1E40BCB715A3494400BD64D9 /* BITCrashReportTextFormatter.h */, @@ -416,6 +422,8 @@ 1E5955F815B77F7C00A03429 /* BITUpdateViewController.h in Headers */, 1E5954B515B6E16300A03429 /* BITUpdateSettingsViewController.h in Headers */, 1E5955F615B77F6500A03429 /* HockeySDKPrivate.h in Headers */, + 1E01118115BB6311007002AC /* BITUpdateManagerPrivate.h in Headers */, + 1E01118215BB6314007002AC /* BITCrashManagerPrivate.h in Headers */, 1E5955F215B77F5100A03429 /* NSString+BITHockeyAdditions.h in Headers */, 1E5955F315B77F5600A03429 /* PSAppStoreHeader.h in Headers */, 1E5954B615B6E17700A03429 /* PSStoreButton.h in Headers */,