mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 11:50:56 +00:00
Some more 2 space indentation fixes
This commit is contained in:
parent
d7afa96cca
commit
ac1ac09411
@ -36,10 +36,10 @@ NSBundle *hockeyBundle(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSString *BWmd5(NSString *str) {
|
NSString *BWmd5(NSString *str) {
|
||||||
const char *cStr = [str UTF8String];
|
const char *cStr = [str UTF8String];
|
||||||
unsigned char result[CC_MD5_DIGEST_LENGTH];
|
unsigned char result[CC_MD5_DIGEST_LENGTH];
|
||||||
CC_MD5( cStr, strlen(cStr), result );
|
CC_MD5( cStr, strlen(cStr), result );
|
||||||
return [NSString
|
return [NSString
|
||||||
stringWithFormat: @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
|
stringWithFormat: @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
|
||||||
result[0], result[1],
|
result[0], result[1],
|
||||||
result[2], result[3],
|
result[2], result[3],
|
||||||
|
|||||||
@ -62,7 +62,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (id)init {
|
- (id)init {
|
||||||
return [self init:[BWHockeyManager sharedHockeyManager]];
|
return [self init:[BWHockeyManager sharedHockeyManager]];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|||||||
@ -295,26 +295,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (CAGradientLayer *)backgroundLayer {
|
- (CAGradientLayer *)backgroundLayer {
|
||||||
UIColor *colorOne = [UIColor colorWithWhite:0.9 alpha:1.0];
|
UIColor *colorOne = [UIColor colorWithWhite:0.9 alpha:1.0];
|
||||||
UIColor *colorTwo = [UIColor colorWithHue:0.625 saturation:0.0 brightness:0.85 alpha:1.0];
|
UIColor *colorTwo = [UIColor colorWithHue:0.625 saturation:0.0 brightness:0.85 alpha:1.0];
|
||||||
UIColor *colorThree = [UIColor colorWithHue:0.625 saturation:0.0 brightness:0.7 alpha:1.0];
|
UIColor *colorThree = [UIColor colorWithHue:0.625 saturation:0.0 brightness:0.7 alpha:1.0];
|
||||||
UIColor *colorFour = [UIColor colorWithHue:0.625 saturation:0.0 brightness:0.4 alpha:1.0];
|
UIColor *colorFour = [UIColor colorWithHue:0.625 saturation:0.0 brightness:0.4 alpha:1.0];
|
||||||
|
|
||||||
NSArray *colors = [NSArray arrayWithObjects:(id)colorOne.CGColor, colorTwo.CGColor, colorThree.CGColor, colorFour.CGColor, nil];
|
NSArray *colors = [NSArray arrayWithObjects:(id)colorOne.CGColor, colorTwo.CGColor, colorThree.CGColor, colorFour.CGColor, nil];
|
||||||
|
|
||||||
NSNumber *stopOne = [NSNumber numberWithFloat:0.0];
|
NSNumber *stopOne = [NSNumber numberWithFloat:0.0];
|
||||||
NSNumber *stopTwo = [NSNumber numberWithFloat:0.02];
|
NSNumber *stopTwo = [NSNumber numberWithFloat:0.02];
|
||||||
NSNumber *stopThree = [NSNumber numberWithFloat:0.99];
|
NSNumber *stopThree = [NSNumber numberWithFloat:0.99];
|
||||||
NSNumber *stopFour = [NSNumber numberWithFloat:1.0];
|
NSNumber *stopFour = [NSNumber numberWithFloat:1.0];
|
||||||
|
|
||||||
NSArray *locations = [NSArray arrayWithObjects:stopOne, stopTwo, stopThree, stopFour, nil];
|
NSArray *locations = [NSArray arrayWithObjects:stopOne, stopTwo, stopThree, stopFour, nil];
|
||||||
|
|
||||||
CAGradientLayer *headerLayer = [CAGradientLayer layer];
|
CAGradientLayer *headerLayer = [CAGradientLayer layer];
|
||||||
//headerLayer.frame = CGRectMake(0.0, 0.0, 320.0, 77.0);
|
//headerLayer.frame = CGRectMake(0.0, 0.0, 320.0, 77.0);
|
||||||
headerLayer.colors = colors;
|
headerLayer.colors = colors;
|
||||||
headerLayer.locations = locations;
|
headerLayer.locations = locations;
|
||||||
|
|
||||||
return headerLayer;
|
return headerLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
|
|||||||
@ -54,31 +54,31 @@ NSString *BWQuincyLocalize(NSString *stringToken);
|
|||||||
#define BWQuincyNetworkBecomeReachable @"NetworkDidBecomeReachable"
|
#define BWQuincyNetworkBecomeReachable @"NetworkDidBecomeReachable"
|
||||||
|
|
||||||
typedef enum QuincyKitAlertType {
|
typedef enum QuincyKitAlertType {
|
||||||
QuincyKitAlertTypeSend = 0,
|
QuincyKitAlertTypeSend = 0,
|
||||||
QuincyKitAlertTypeFeedback = 1,
|
QuincyKitAlertTypeFeedback = 1,
|
||||||
} CrashAlertType;
|
} CrashAlertType;
|
||||||
|
|
||||||
typedef enum CrashReportStatus {
|
typedef enum CrashReportStatus {
|
||||||
// The status of the crash is queued, need to check later (HockeyApp)
|
// The status of the crash is queued, need to check later (HockeyApp)
|
||||||
CrashReportStatusQueued = -80,
|
CrashReportStatusQueued = -80,
|
||||||
|
|
||||||
// This app version is set to discontinued, no new crash reports accepted by the server
|
// This app version is set to discontinued, no new crash reports accepted by the server
|
||||||
CrashReportStatusFailureVersionDiscontinued = -30,
|
CrashReportStatusFailureVersionDiscontinued = -30,
|
||||||
|
|
||||||
// XML: Sender version string contains not allowed characters, only alphanumberical including space and . are allowed
|
// XML: Sender version string contains not allowed characters, only alphanumberical including space and . are allowed
|
||||||
CrashReportStatusFailureXMLSenderVersionNotAllowed = -21,
|
CrashReportStatusFailureXMLSenderVersionNotAllowed = -21,
|
||||||
|
|
||||||
// XML: Version string contains not allowed characters, only alphanumberical including space and . are allowed
|
// XML: Version string contains not allowed characters, only alphanumberical including space and . are allowed
|
||||||
CrashReportStatusFailureXMLVersionNotAllowed = -20,
|
CrashReportStatusFailureXMLVersionNotAllowed = -20,
|
||||||
|
|
||||||
// SQL for adding a symoblicate todo entry in the database failed
|
// SQL for adding a symoblicate todo entry in the database failed
|
||||||
CrashReportStatusFailureSQLAddSymbolicateTodo = -18,
|
CrashReportStatusFailureSQLAddSymbolicateTodo = -18,
|
||||||
|
|
||||||
// SQL for adding crash log in the database failed
|
// SQL for adding crash log in the database failed
|
||||||
CrashReportStatusFailureSQLAddCrashlog = -17,
|
CrashReportStatusFailureSQLAddCrashlog = -17,
|
||||||
|
|
||||||
// SQL for adding a new version in the database failed
|
// SQL for adding a new version in the database failed
|
||||||
CrashReportStatusFailureSQLAddVersion = -16,
|
CrashReportStatusFailureSQLAddVersion = -16,
|
||||||
|
|
||||||
// SQL for checking if the version is already added in the database failed
|
// SQL for checking if the version is already added in the database failed
|
||||||
CrashReportStatusFailureSQLCheckVersionExists = -15,
|
CrashReportStatusFailureSQLCheckVersionExists = -15,
|
||||||
@ -162,19 +162,19 @@ typedef enum CrashReportStatus {
|
|||||||
NSString *_feedbackRequestID;
|
NSString *_feedbackRequestID;
|
||||||
float _feedbackDelayInterval;
|
float _feedbackDelayInterval;
|
||||||
|
|
||||||
NSMutableString *_contentOfProperty;
|
NSMutableString *_contentOfProperty;
|
||||||
CrashReportStatus _serverResult;
|
CrashReportStatus _serverResult;
|
||||||
|
|
||||||
int _analyzerStarted;
|
int _analyzerStarted;
|
||||||
NSString *_crashesDir;
|
NSString *_crashesDir;
|
||||||
|
|
||||||
BOOL _crashIdenticalCurrentVersion;
|
BOOL _crashIdenticalCurrentVersion;
|
||||||
BOOL _crashReportActivated;
|
BOOL _crashReportActivated;
|
||||||
|
|
||||||
NSMutableArray *_crashFiles;
|
NSMutableArray *_crashFiles;
|
||||||
|
|
||||||
NSMutableData *_responseData;
|
NSMutableData *_responseData;
|
||||||
NSInteger _statusCode;
|
NSInteger _statusCode;
|
||||||
|
|
||||||
NSURLConnection *_urlConnection;
|
NSURLConnection *_urlConnection;
|
||||||
|
|
||||||
|
|||||||
@ -92,8 +92,7 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
@synthesize appIdentifier = _appIdentifier;
|
@synthesize appIdentifier = _appIdentifier;
|
||||||
|
|
||||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000
|
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000
|
||||||
+(BWQuincyManager *)sharedQuincyManager
|
+(BWQuincyManager *)sharedQuincyManager {
|
||||||
{
|
|
||||||
static BWQuincyManager *sharedInstance = nil;
|
static BWQuincyManager *sharedInstance = nil;
|
||||||
static dispatch_once_t pred;
|
static dispatch_once_t pred;
|
||||||
|
|
||||||
@ -106,23 +105,23 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
+ (BWQuincyManager *)sharedQuincyManager {
|
+ (BWQuincyManager *)sharedQuincyManager {
|
||||||
static BWQuincyManager *quincyManager = nil;
|
static BWQuincyManager *quincyManager = nil;
|
||||||
|
|
||||||
if (quincyManager == nil) {
|
if (quincyManager == nil) {
|
||||||
quincyManager = [[BWQuincyManager alloc] init];
|
quincyManager = [[BWQuincyManager alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
return quincyManager;
|
return quincyManager;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
- (id) init {
|
- (id) init {
|
||||||
if ((self = [super init])) {
|
if ((self = [super init])) {
|
||||||
_serverResult = CrashReportStatusUnknown;
|
_serverResult = CrashReportStatusUnknown;
|
||||||
_crashIdenticalCurrentVersion = YES;
|
_crashIdenticalCurrentVersion = YES;
|
||||||
_crashData = nil;
|
_crashData = nil;
|
||||||
_urlConnection = nil;
|
_urlConnection = nil;
|
||||||
_submissionURL = nil;
|
_submissionURL = nil;
|
||||||
_responseData = nil;
|
_responseData = nil;
|
||||||
_appIdentifier = nil;
|
_appIdentifier = nil;
|
||||||
_sendingInProgress = NO;
|
_sendingInProgress = NO;
|
||||||
@ -130,63 +129,63 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
_didCrashInLastSession = NO;
|
_didCrashInLastSession = NO;
|
||||||
_loggingEnabled = NO;
|
_loggingEnabled = NO;
|
||||||
|
|
||||||
self.delegate = nil;
|
self.delegate = nil;
|
||||||
self.feedbackActivated = NO;
|
self.feedbackActivated = NO;
|
||||||
self.showAlwaysButton = NO;
|
self.showAlwaysButton = NO;
|
||||||
self.autoSubmitCrashReport = NO;
|
self.autoSubmitCrashReport = NO;
|
||||||
self.autoSubmitDeviceUDID = NO;
|
self.autoSubmitDeviceUDID = NO;
|
||||||
|
|
||||||
NSString *testValue = [[NSUserDefaults standardUserDefaults] stringForKey:kQuincyKitAnalyzerStarted];
|
NSString *testValue = [[NSUserDefaults standardUserDefaults] stringForKey:kQuincyKitAnalyzerStarted];
|
||||||
if (testValue) {
|
if (testValue) {
|
||||||
_analyzerStarted = [[NSUserDefaults standardUserDefaults] integerForKey:kQuincyKitAnalyzerStarted];
|
_analyzerStarted = [[NSUserDefaults standardUserDefaults] integerForKey:kQuincyKitAnalyzerStarted];
|
||||||
} else {
|
} else {
|
||||||
_analyzerStarted = 0;
|
_analyzerStarted = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
testValue = nil;
|
testValue = nil;
|
||||||
testValue = [[NSUserDefaults standardUserDefaults] stringForKey:kQuincyKitActivated];
|
testValue = [[NSUserDefaults standardUserDefaults] stringForKey:kQuincyKitActivated];
|
||||||
if (testValue) {
|
if (testValue) {
|
||||||
_crashReportActivated = [[NSUserDefaults standardUserDefaults] boolForKey:kQuincyKitActivated];
|
_crashReportActivated = [[NSUserDefaults standardUserDefaults] boolForKey:kQuincyKitActivated];
|
||||||
} else {
|
} else {
|
||||||
_crashReportActivated = YES;
|
_crashReportActivated = YES;
|
||||||
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithBool:YES] forKey:kQuincyKitActivated];
|
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithBool:YES] forKey:kQuincyKitActivated];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_crashReportActivated) {
|
if (_crashReportActivated) {
|
||||||
_crashFiles = [[NSMutableArray alloc] init];
|
_crashFiles = [[NSMutableArray alloc] init];
|
||||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||||
_crashesDir = [[NSString stringWithFormat:@"%@", [[paths objectAtIndex:0] stringByAppendingPathComponent:@"/crashes/"]] retain];
|
_crashesDir = [[NSString stringWithFormat:@"%@", [[paths objectAtIndex:0] stringByAppendingPathComponent:@"/crashes/"]] retain];
|
||||||
|
|
||||||
NSFileManager *fm = [NSFileManager defaultManager];
|
NSFileManager *fm = [NSFileManager defaultManager];
|
||||||
|
|
||||||
if (![fm fileExistsAtPath:_crashesDir]) {
|
if (![fm fileExistsAtPath:_crashesDir]) {
|
||||||
NSDictionary *attributes = [NSDictionary dictionaryWithObject: [NSNumber numberWithUnsignedLong: 0755] forKey: NSFilePosixPermissions];
|
NSDictionary *attributes = [NSDictionary dictionaryWithObject: [NSNumber numberWithUnsignedLong: 0755] forKey: NSFilePosixPermissions];
|
||||||
NSError *theError = NULL;
|
NSError *theError = NULL;
|
||||||
|
|
||||||
[fm createDirectoryAtPath:_crashesDir withIntermediateDirectories: YES attributes: attributes error: &theError];
|
[fm createDirectoryAtPath:_crashesDir withIntermediateDirectories: YES attributes: attributes error: &theError];
|
||||||
}
|
|
||||||
|
|
||||||
PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
|
|
||||||
NSError *error = NULL;
|
|
||||||
|
|
||||||
// Check if we previously crashed
|
|
||||||
if ([crashReporter hasPendingCrashReport]) {
|
|
||||||
_didCrashInLastSession = YES;
|
|
||||||
[self handleCrashReport];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable the Crash Reporter
|
PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
|
||||||
if (![crashReporter enableCrashReporterAndReturnError: &error])
|
NSError *error = NULL;
|
||||||
NSLog(@"WARNING: Could not enable crash reporter: %@", error);
|
|
||||||
|
// Check if we previously crashed
|
||||||
|
if ([crashReporter hasPendingCrashReport]) {
|
||||||
|
_didCrashInLastSession = YES;
|
||||||
|
[self handleCrashReport];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable the Crash Reporter
|
||||||
|
if (![crashReporter enableCrashReporterAndReturnError: &error])
|
||||||
|
NSLog(@"WARNING: Could not enable crash reporter: %@", error);
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startManager) name:BWQuincyNetworkBecomeReachable object:nil];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startManager) name:BWQuincyNetworkBecomeReachable object:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!quincyBundle()) {
|
if (!quincyBundle()) {
|
||||||
NSLog(@"WARNING: Quincy.bundle is missing, will send reports automatically!");
|
NSLog(@"WARNING: Quincy.bundle is missing, will send reports automatically!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -208,10 +207,10 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
|
|
||||||
[_crashData release];
|
[_crashData release];
|
||||||
|
|
||||||
[_crashesDir release];
|
[_crashesDir release];
|
||||||
[_crashFiles release];
|
[_crashFiles release];
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -292,8 +291,8 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
|
|
||||||
if (!approvedCrashReports || [approvedCrashReports count] == 0) return YES;
|
if (!approvedCrashReports || [approvedCrashReports count] == 0) return YES;
|
||||||
|
|
||||||
for (NSUInteger i=0; i < [_crashFiles count]; i++) {
|
for (NSUInteger i=0; i < [_crashFiles count]; i++) {
|
||||||
NSString *filename = [_crashFiles objectAtIndex:i];
|
NSString *filename = [_crashFiles objectAtIndex:i];
|
||||||
|
|
||||||
if (![approvedCrashReports objectForKey:filename]) return YES;
|
if (![approvedCrashReports objectForKey:filename]) return YES;
|
||||||
}
|
}
|
||||||
@ -330,46 +329,46 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
|
|
||||||
|
|
||||||
- (void) showCrashStatusMessage {
|
- (void) showCrashStatusMessage {
|
||||||
UIAlertView *alertView = nil;
|
UIAlertView *alertView = nil;
|
||||||
|
|
||||||
if (_serverResult >= CrashReportStatusAssigned &&
|
if (_serverResult >= CrashReportStatusAssigned &&
|
||||||
_crashIdenticalCurrentVersion &&
|
_crashIdenticalCurrentVersion &&
|
||||||
quincyBundle()) {
|
quincyBundle()) {
|
||||||
// show some feedback to the user about the crash status
|
// show some feedback to the user about the crash status
|
||||||
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||||
switch (_serverResult) {
|
switch (_serverResult) {
|
||||||
case CrashReportStatusAssigned:
|
case CrashReportStatusAssigned:
|
||||||
alertView = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseTitle"), appName ]
|
alertView = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseTitle"), appName ]
|
||||||
message: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseNextRelease"), appName]
|
message: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseNextRelease"), appName]
|
||||||
delegate: self
|
delegate: self
|
||||||
cancelButtonTitle: BWQuincyLocalize(@"CrashResponseTitleOK")
|
cancelButtonTitle: BWQuincyLocalize(@"CrashResponseTitleOK")
|
||||||
otherButtonTitles: nil];
|
otherButtonTitles: nil];
|
||||||
break;
|
break;
|
||||||
case CrashReportStatusSubmitted:
|
case CrashReportStatusSubmitted:
|
||||||
alertView = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseTitle"), appName ]
|
alertView = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseTitle"), appName ]
|
||||||
message: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseWaitingApple"), appName]
|
message: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseWaitingApple"), appName]
|
||||||
delegate: self
|
delegate: self
|
||||||
cancelButtonTitle: BWQuincyLocalize(@"CrashResponseTitleOK")
|
cancelButtonTitle: BWQuincyLocalize(@"CrashResponseTitleOK")
|
||||||
otherButtonTitles: nil];
|
otherButtonTitles: nil];
|
||||||
break;
|
break;
|
||||||
case CrashReportStatusAvailable:
|
case CrashReportStatusAvailable:
|
||||||
alertView = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseTitle"), appName ]
|
alertView = [[UIAlertView alloc] initWithTitle: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseTitle"), appName ]
|
||||||
message: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseAvailable"), appName]
|
message: [NSString stringWithFormat:BWQuincyLocalize(@"CrashResponseAvailable"), appName]
|
||||||
delegate: self
|
delegate: self
|
||||||
cancelButtonTitle: BWQuincyLocalize(@"CrashResponseTitleOK")
|
cancelButtonTitle: BWQuincyLocalize(@"CrashResponseTitleOK")
|
||||||
otherButtonTitles: nil];
|
otherButtonTitles: nil];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
alertView = nil;
|
alertView = nil;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alertView) {
|
if (alertView) {
|
||||||
[alertView setTag: QuincyKitAlertTypeFeedback];
|
[alertView setTag: QuincyKitAlertTypeFeedback];
|
||||||
[alertView show];
|
[alertView show];
|
||||||
[alertView release];
|
[alertView release];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -410,40 +409,40 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
#pragma mark NSXMLParser
|
#pragma mark NSXMLParser
|
||||||
|
|
||||||
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
|
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
|
||||||
if (qName) {
|
if (qName) {
|
||||||
elementName = qName;
|
elementName = qName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([elementName isEqualToString:@"result"]) {
|
if ([elementName isEqualToString:@"result"]) {
|
||||||
_contentOfProperty = [NSMutableString string];
|
_contentOfProperty = [NSMutableString string];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
|
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
|
||||||
if (qName) {
|
if (qName) {
|
||||||
elementName = qName;
|
elementName = qName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open source implementation
|
// open source implementation
|
||||||
if ([elementName isEqualToString: @"result"]) {
|
if ([elementName isEqualToString: @"result"]) {
|
||||||
if ([_contentOfProperty intValue] > _serverResult) {
|
if ([_contentOfProperty intValue] > _serverResult) {
|
||||||
_serverResult = (CrashReportStatus)[_contentOfProperty intValue];
|
_serverResult = (CrashReportStatus)[_contentOfProperty intValue];
|
||||||
} else {
|
} else {
|
||||||
CrashReportStatus errorcode = (CrashReportStatus)[_contentOfProperty intValue];
|
CrashReportStatus errorcode = (CrashReportStatus)[_contentOfProperty intValue];
|
||||||
NSLog(@"CrashReporter ended in error code: %i", errorcode);
|
NSLog(@"CrashReporter ended in error code: %i", errorcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
|
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
|
||||||
if (_contentOfProperty) {
|
if (_contentOfProperty) {
|
||||||
// If the current element is one whose content we care about, append 'string'
|
// If the current element is one whose content we care about, append 'string'
|
||||||
// to the property that holds the content of the current element.
|
// to the property that holds the content of the current element.
|
||||||
if (string != nil) {
|
if (string != nil) {
|
||||||
[_contentOfProperty appendString:string];
|
[_contentOfProperty appendString:string];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
@ -451,13 +450,13 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
|
|
||||||
|
|
||||||
- (NSString *)_getDevicePlatform {
|
- (NSString *)_getDevicePlatform {
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
|
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
|
||||||
char *answer = (char*)malloc(size);
|
char *answer = (char*)malloc(size);
|
||||||
sysctlbyname("hw.machine", answer, &size, NULL, 0);
|
sysctlbyname("hw.machine", answer, &size, NULL, 0);
|
||||||
NSString *platform = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];
|
NSString *platform = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];
|
||||||
free(answer);
|
free(answer);
|
||||||
return platform;
|
return platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)deviceIdentifier {
|
- (NSString *)deviceIdentifier {
|
||||||
@ -473,52 +472,52 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
NSMutableDictionary *approvedCrashReports = [NSMutableDictionary dictionaryWithDictionary:[[NSUserDefaults standardUserDefaults] dictionaryForKey: kApprovedCrashReports]];
|
NSMutableDictionary *approvedCrashReports = [NSMutableDictionary dictionaryWithDictionary:[[NSUserDefaults standardUserDefaults] dictionaryForKey: kApprovedCrashReports]];
|
||||||
|
|
||||||
NSFileManager *fm = [NSFileManager defaultManager];
|
NSFileManager *fm = [NSFileManager defaultManager];
|
||||||
NSError *error = NULL;
|
NSError *error = NULL;
|
||||||
|
|
||||||
NSString *userid = @"";
|
NSString *userid = @"";
|
||||||
NSString *contact = @"";
|
NSString *contact = @"";
|
||||||
NSString *description = @"";
|
NSString *description = @"";
|
||||||
|
|
||||||
if (self.autoSubmitDeviceUDID && [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
|
if (self.autoSubmitDeviceUDID && [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
|
||||||
userid = [self deviceIdentifier];
|
userid = [self deviceIdentifier];
|
||||||
} else if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashReportUserID)]) {
|
} else if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashReportUserID)]) {
|
||||||
userid = [self.delegate crashReportUserID] ?: @"";
|
userid = [self.delegate crashReportUserID] ?: @"";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashReportContact)]) {
|
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashReportContact)]) {
|
||||||
contact = [self.delegate crashReportContact] ?: @"";
|
contact = [self.delegate crashReportContact] ?: @"";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashReportDescription)]) {
|
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashReportDescription)]) {
|
||||||
description = [self.delegate crashReportDescription] ?: @"";
|
description = [self.delegate crashReportDescription] ?: @"";
|
||||||
}
|
}
|
||||||
|
|
||||||
NSMutableString *crashes = nil;
|
NSMutableString *crashes = nil;
|
||||||
_crashIdenticalCurrentVersion = NO;
|
_crashIdenticalCurrentVersion = NO;
|
||||||
|
|
||||||
for (NSUInteger i=0; i < [_crashFiles count]; i++) {
|
for (NSUInteger i=0; i < [_crashFiles count]; i++) {
|
||||||
NSString *filename = [_crashesDir stringByAppendingPathComponent:[_crashFiles objectAtIndex:i]];
|
NSString *filename = [_crashesDir stringByAppendingPathComponent:[_crashFiles objectAtIndex:i]];
|
||||||
NSData *crashData = [NSData dataWithContentsOfFile:filename];
|
NSData *crashData = [NSData dataWithContentsOfFile:filename];
|
||||||
|
|
||||||
if ([crashData length] > 0) {
|
if ([crashData length] > 0) {
|
||||||
PLCrashReport *report = [[[PLCrashReport alloc] initWithData:crashData error:&error] autorelease];
|
PLCrashReport *report = [[[PLCrashReport alloc] initWithData:crashData error:&error] autorelease];
|
||||||
|
|
||||||
if (report == nil) {
|
if (report == nil) {
|
||||||
NSLog(@"Could not parse crash report");
|
NSLog(@"Could not parse crash report");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *crashLogString = [PLCrashReportTextFormatter stringValueForCrashReport:report withTextFormat:PLCrashReportTextFormatiOS];
|
NSString *crashLogString = [PLCrashReportTextFormatter stringValueForCrashReport:report withTextFormat:PLCrashReportTextFormatiOS];
|
||||||
|
|
||||||
if ([report.applicationInfo.applicationVersion compare:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] == NSOrderedSame) {
|
if ([report.applicationInfo.applicationVersion compare:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] == NSOrderedSame) {
|
||||||
_crashIdenticalCurrentVersion = YES;
|
_crashIdenticalCurrentVersion = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crashes == nil) {
|
if (crashes == nil) {
|
||||||
crashes = [NSMutableString string];
|
crashes = [NSMutableString string];
|
||||||
}
|
}
|
||||||
|
|
||||||
[crashes appendFormat:@"<crash><applicationname>%s</applicationname><bundleidentifier>%@</bundleidentifier><systemversion>%@</systemversion><platform>%@</platform><senderversion>%@</senderversion><version>%@</version><log><![CDATA[%@]]></log><userid>%@</userid><contact>%@</contact><description><![CDATA[%@]]></description></crash>",
|
[crashes appendFormat:@"<crash><applicationname>%s</applicationname><bundleidentifier>%@</bundleidentifier><systemversion>%@</systemversion><platform>%@</platform><senderversion>%@</senderversion><version>%@</version><log><![CDATA[%@]]></log><userid>%@</userid><contact>%@</contact><description><![CDATA[%@]]></description></crash>",
|
||||||
[[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"] UTF8String],
|
[[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"] UTF8String],
|
||||||
report.applicationInfo.applicationIdentifier,
|
report.applicationInfo.applicationIdentifier,
|
||||||
report.systemInfo.operatingSystemVersion,
|
report.systemInfo.operatingSystemVersion,
|
||||||
@ -528,16 +527,16 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
[crashLogString stringByReplacingOccurrencesOfString:@"]]>" withString:@"]]" @"]]><![CDATA[" @">" options:NSLiteralSearch range:NSMakeRange(0,crashLogString.length)],
|
[crashLogString stringByReplacingOccurrencesOfString:@"]]>" withString:@"]]" @"]]><![CDATA[" @">" options:NSLiteralSearch range:NSMakeRange(0,crashLogString.length)],
|
||||||
userid,
|
userid,
|
||||||
contact,
|
contact,
|
||||||
[description stringByReplacingOccurrencesOfString:@"]]>" withString:@"]]" @"]]><![CDATA[" @">" options:NSLiteralSearch range:NSMakeRange(0,description.length)]];
|
[description stringByReplacingOccurrencesOfString:@"]]>" withString:@"]]" @"]]><![CDATA[" @">" options:NSLiteralSearch range:NSMakeRange(0,description.length)]];
|
||||||
|
|
||||||
|
|
||||||
// store this crash report as user approved, so if it fails it will retry automatically
|
// store this crash report as user approved, so if it fails it will retry automatically
|
||||||
[approvedCrashReports setObject:[NSNumber numberWithBool:YES] forKey:[_crashFiles objectAtIndex:i]];
|
[approvedCrashReports setObject:[NSNumber numberWithBool:YES] forKey:[_crashFiles objectAtIndex:i]];
|
||||||
} else {
|
} else {
|
||||||
// we cannot do anything with this report, so delete it
|
// we cannot do anything with this report, so delete it
|
||||||
[fm removeItemAtPath:filename error:&error];
|
[fm removeItemAtPath:filename error:&error];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:approvedCrashReports forKey:kApprovedCrashReports];
|
[[NSUserDefaults standardUserDefaults] setObject:approvedCrashReports forKey:kApprovedCrashReports];
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
@ -572,58 +571,60 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
- (void)_checkForFeedbackStatus {
|
- (void)_checkForFeedbackStatus {
|
||||||
NSMutableURLRequest *request = nil;
|
NSMutableURLRequest *request = nil;
|
||||||
|
|
||||||
request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@api/2/apps/%@/crashes/%@",
|
request = [NSMutableURLRequest requestWithURL:
|
||||||
self.submissionURL,
|
[NSURL URLWithString:[NSString stringWithFormat:@"%@api/2/apps/%@/crashes/%@",
|
||||||
[self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
|
self.submissionURL,
|
||||||
_feedbackRequestID
|
[self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
|
||||||
]
|
_feedbackRequestID
|
||||||
]];
|
]
|
||||||
|
]];
|
||||||
|
|
||||||
[request setCachePolicy: NSURLRequestReloadIgnoringLocalCacheData];
|
[request setCachePolicy: NSURLRequestReloadIgnoringLocalCacheData];
|
||||||
[request setValue:@"Quincy/iOS" forHTTPHeaderField:@"User-Agent"];
|
[request setValue:@"Quincy/iOS" forHTTPHeaderField:@"User-Agent"];
|
||||||
[request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
|
[request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
|
||||||
[request setTimeoutInterval: 15];
|
[request setTimeoutInterval: 15];
|
||||||
[request setHTTPMethod:@"GET"];
|
[request setHTTPMethod:@"GET"];
|
||||||
|
|
||||||
_serverResult = CrashReportStatusUnknown;
|
_serverResult = CrashReportStatusUnknown;
|
||||||
_statusCode = 200;
|
_statusCode = 200;
|
||||||
|
|
||||||
// Release when done in the delegate method
|
// Release when done in the delegate method
|
||||||
_responseData = [[NSMutableData alloc] init];
|
_responseData = [[NSMutableData alloc] init];
|
||||||
|
|
||||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(connectionOpened)]) {
|
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(connectionOpened)]) {
|
||||||
[self.delegate connectionOpened];
|
[self.delegate connectionOpened];
|
||||||
}
|
}
|
||||||
|
|
||||||
_urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
|
_urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
|
||||||
|
|
||||||
BWQuincyLog(@"Requesting feedback status.");
|
BWQuincyLog(@"Requesting feedback status.");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_postXML:(NSString*)xml toURL:(NSURL*)url {
|
- (void)_postXML:(NSString*)xml toURL:(NSURL*)url {
|
||||||
NSMutableURLRequest *request = nil;
|
NSMutableURLRequest *request = nil;
|
||||||
NSString *boundary = @"----FOO";
|
NSString *boundary = @"----FOO";
|
||||||
|
|
||||||
if (self.appIdentifier) {
|
if (self.appIdentifier) {
|
||||||
request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@api/2/apps/%@/crashes",
|
request = [NSMutableURLRequest requestWithURL:
|
||||||
self.submissionURL,
|
[NSURL URLWithString:[NSString stringWithFormat:@"%@api/2/apps/%@/crashes",
|
||||||
[self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
|
self.submissionURL,
|
||||||
]
|
[self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
|
||||||
]];
|
]
|
||||||
|
]];
|
||||||
} else {
|
} else {
|
||||||
request = [NSMutableURLRequest requestWithURL:url];
|
request = [NSMutableURLRequest requestWithURL:url];
|
||||||
}
|
}
|
||||||
|
|
||||||
[request setCachePolicy: NSURLRequestReloadIgnoringLocalCacheData];
|
[request setCachePolicy: NSURLRequestReloadIgnoringLocalCacheData];
|
||||||
[request setValue:@"Quincy/iOS" forHTTPHeaderField:@"User-Agent"];
|
[request setValue:@"Quincy/iOS" forHTTPHeaderField:@"User-Agent"];
|
||||||
[request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
|
[request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
|
||||||
[request setTimeoutInterval: 15];
|
[request setTimeoutInterval: 15];
|
||||||
[request setHTTPMethod:@"POST"];
|
[request setHTTPMethod:@"POST"];
|
||||||
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
|
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
|
||||||
[request setValue:contentType forHTTPHeaderField:@"Content-type"];
|
[request setValue:contentType forHTTPHeaderField:@"Content-type"];
|
||||||
|
|
||||||
NSMutableData *postBody = [NSMutableData data];
|
NSMutableData *postBody = [NSMutableData data];
|
||||||
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
|
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||||
if (self.appIdentifier) {
|
if (self.appIdentifier) {
|
||||||
[postBody appendData:[@"Content-Disposition: form-data; name=\"xml\"; filename=\"crash.xml\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
|
[postBody appendData:[@"Content-Disposition: form-data; name=\"xml\"; filename=\"crash.xml\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
|
||||||
[postBody appendData:[[NSString stringWithFormat:@"Content-Type: text/xml\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
|
[postBody appendData:[[NSString stringWithFormat:@"Content-Type: text/xml\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||||
@ -635,17 +636,17 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
|
|
||||||
[request setHTTPBody:postBody];
|
[request setHTTPBody:postBody];
|
||||||
|
|
||||||
_serverResult = CrashReportStatusUnknown;
|
_serverResult = CrashReportStatusUnknown;
|
||||||
_statusCode = 200;
|
_statusCode = 200;
|
||||||
|
|
||||||
//Release when done in the delegate method
|
//Release when done in the delegate method
|
||||||
_responseData = [[NSMutableData alloc] init];
|
_responseData = [[NSMutableData alloc] init];
|
||||||
|
|
||||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(connectionOpened)]) {
|
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(connectionOpened)]) {
|
||||||
[self.delegate connectionOpened];
|
[self.delegate connectionOpened];
|
||||||
}
|
}
|
||||||
|
|
||||||
_urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
|
_urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
|
||||||
|
|
||||||
if (!_urlConnection) {
|
if (!_urlConnection) {
|
||||||
BWQuincyLog(@"Sending crash reports could not start!");
|
BWQuincyLog(@"Sending crash reports could not start!");
|
||||||
@ -658,13 +659,13 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
#pragma mark NSURLConnection Delegate
|
#pragma mark NSURLConnection Delegate
|
||||||
|
|
||||||
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
|
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
|
||||||
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
|
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||||
_statusCode = [(NSHTTPURLResponse *)response statusCode];
|
_statusCode = [(NSHTTPURLResponse *)response statusCode];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
|
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
|
||||||
[_responseData appendData:data];
|
[_responseData appendData:data];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
|
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
|
||||||
@ -754,15 +755,15 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
// Called to handle a pending crash report.
|
// Called to handle a pending crash report.
|
||||||
//
|
//
|
||||||
- (void) handleCrashReport {
|
- (void) handleCrashReport {
|
||||||
PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
|
PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
|
||||||
NSError *error = NULL;
|
NSError *error = NULL;
|
||||||
|
|
||||||
// check if the next call ran successfully the last time
|
// check if the next call ran successfully the last time
|
||||||
if (_analyzerStarted == 0) {
|
if (_analyzerStarted == 0) {
|
||||||
// mark the start of the routine
|
// mark the start of the routine
|
||||||
_analyzerStarted = 1;
|
_analyzerStarted = 1;
|
||||||
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:_analyzerStarted] forKey:kQuincyKitAnalyzerStarted];
|
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:_analyzerStarted] forKey:kQuincyKitAnalyzerStarted];
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
|
|
||||||
// Try loading the crash report
|
// Try loading the crash report
|
||||||
_crashData = [[NSData alloc] initWithData:[crashReporter loadPendingCrashReportDataAndReturnError: &error]];
|
_crashData = [[NSData alloc] initWithData:[crashReporter loadPendingCrashReportDataAndReturnError: &error]];
|
||||||
@ -773,17 +774,17 @@ NSString *BWQuincyLocalize(NSString *stringToken) {
|
|||||||
NSLog(@"Could not load crash report: %@", error);
|
NSLog(@"Could not load crash report: %@", error);
|
||||||
} else {
|
} else {
|
||||||
[_crashData writeToFile:[_crashesDir stringByAppendingPathComponent: cacheFilename] atomically:YES];
|
[_crashData writeToFile:[_crashesDir stringByAppendingPathComponent: cacheFilename] atomically:YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Purge the report
|
// Purge the report
|
||||||
// mark the end of the routine
|
// mark the end of the routine
|
||||||
_analyzerStarted = 0;
|
_analyzerStarted = 0;
|
||||||
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:_analyzerStarted] forKey:kQuincyKitAnalyzerStarted];
|
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:_analyzerStarted] forKey:kQuincyKitAnalyzerStarted];
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
|
|
||||||
[crashReporter purgePendingCrashReport];
|
[crashReporter purgePendingCrashReport];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -51,13 +51,13 @@
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
+ (CNSHockeyManager *)sharedHockeyManager {
|
+ (CNSHockeyManager *)sharedHockeyManager {
|
||||||
static CNSHockeyManager *hockeyManager = nil;
|
static CNSHockeyManager *hockeyManager = nil;
|
||||||
|
|
||||||
if (hockeyManager == nil) {
|
if (hockeyManager == nil) {
|
||||||
hockeyManager = [[CNSHockeyManager alloc] init];
|
hockeyManager = [[CNSHockeyManager alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
return hockeyManager;
|
return hockeyManager;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -51,29 +51,28 @@ CNS_FIX_CATEGORY_BUG(NSString_HockeyAdditions)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSComparisonResult)versionCompare:(NSString *)other
|
- (NSComparisonResult)versionCompare:(NSString *)other {
|
||||||
{
|
// Extract plain version number from self
|
||||||
// Extract plain version number from self
|
NSString *plainSelf = self;
|
||||||
NSString *plainSelf = self;
|
NSRange letterRange = [plainSelf rangeOfCharacterFromSet: [NSCharacterSet letterCharacterSet]];
|
||||||
NSRange letterRange = [plainSelf rangeOfCharacterFromSet: [NSCharacterSet letterCharacterSet]];
|
if (letterRange.length)
|
||||||
if (letterRange.length)
|
plainSelf = [plainSelf substringToIndex: letterRange.location];
|
||||||
plainSelf = [plainSelf substringToIndex: letterRange.location];
|
|
||||||
|
|
||||||
// Extract plain version number from other
|
// Extract plain version number from other
|
||||||
NSString *plainOther = other;
|
NSString *plainOther = other;
|
||||||
letterRange = [plainOther rangeOfCharacterFromSet: [NSCharacterSet letterCharacterSet]];
|
letterRange = [plainOther rangeOfCharacterFromSet: [NSCharacterSet letterCharacterSet]];
|
||||||
if (letterRange.length)
|
if (letterRange.length)
|
||||||
plainOther = [plainOther substringToIndex: letterRange.location];
|
plainOther = [plainOther substringToIndex: letterRange.location];
|
||||||
|
|
||||||
// Compare plain versions
|
// Compare plain versions
|
||||||
NSComparisonResult result = [plainSelf compare:plainOther options:NSNumericSearch];
|
NSComparisonResult result = [plainSelf compare:plainOther options:NSNumericSearch];
|
||||||
|
|
||||||
// If plain versions are equal, compare full versions
|
// If plain versions are equal, compare full versions
|
||||||
if (result == NSOrderedSame)
|
if (result == NSOrderedSame)
|
||||||
result = [self compare:other options:NSNumericSearch];
|
result = [self compare:other options:NSNumericSearch];
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -232,8 +232,8 @@
|
|||||||
|
|
||||||
- (CGSize)sizeThatFits:(CGSize)size {
|
- (CGSize)sizeThatFits:(CGSize)size {
|
||||||
CGSize constr = (CGSize){.height = self.frame.size.height, .width = PS_MAX_WIDTH};
|
CGSize constr = (CGSize){.height = self.frame.size.height, .width = PS_MAX_WIDTH};
|
||||||
CGSize newSize = [self.buttonData.label sizeWithFont:self.titleLabel.font constrainedToSize:constr lineBreakMode:UILineBreakModeMiddleTruncation];
|
CGSize newSize = [self.buttonData.label sizeWithFont:self.titleLabel.font constrainedToSize:constr lineBreakMode:UILineBreakModeMiddleTruncation];
|
||||||
CGFloat newWidth = newSize.width + (PS_PADDING * 2);
|
CGFloat newWidth = newSize.width + (PS_PADDING * 2);
|
||||||
CGFloat newHeight = PS_MIN_HEIGHT > newSize.height ? PS_MIN_HEIGHT : newSize.height;
|
CGFloat newHeight = PS_MIN_HEIGHT > newSize.height ? PS_MIN_HEIGHT : newSize.height;
|
||||||
|
|
||||||
CGSize sizeThatFits = CGSizeMake(newWidth, newHeight);
|
CGSize sizeThatFits = CGSizeMake(newWidth, newHeight);
|
||||||
@ -250,7 +250,7 @@
|
|||||||
rect.size.height = self.frame.size.height;
|
rect.size.height = self.frame.size.height;
|
||||||
aLayer.frame = rect;
|
aLayer.frame = rect;
|
||||||
[aLayer layoutIfNeeded];
|
[aLayer layoutIfNeeded];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -52,15 +52,15 @@ body { font: 13px 'Helvetica Neue', Helvetica; word-wrap:break-word; padding:8px
|
|||||||
#pragma mark private
|
#pragma mark private
|
||||||
|
|
||||||
- (void)addWebView {
|
- (void)addWebView {
|
||||||
if(webViewContent_) {
|
if(webViewContent_) {
|
||||||
CGRect webViewRect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
|
CGRect webViewRect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
|
||||||
if(!webView_) {
|
if(!webView_) {
|
||||||
webView_ = [[[UIWebView alloc] initWithFrame:webViewRect] retain];
|
webView_ = [[[UIWebView alloc] initWithFrame:webViewRect] retain];
|
||||||
[self addSubview:webView_];
|
[self addSubview:webView_];
|
||||||
webView_.hidden = YES;
|
webView_.hidden = YES;
|
||||||
webView_.backgroundColor = self.cellBackgroundColor;
|
webView_.backgroundColor = self.cellBackgroundColor;
|
||||||
webView_.opaque = NO;
|
webView_.opaque = NO;
|
||||||
webView_.delegate = self;
|
webView_.delegate = self;
|
||||||
webView_.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
webView_.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||||
|
|
||||||
for(UIView* subView in webView_.subviews){
|
for(UIView* subView in webView_.subviews){
|
||||||
@ -79,32 +79,32 @@ body { font: 13px 'Helvetica Neue', Helvetica; word-wrap:break-word; padding:8px
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
webView_.frame = webViewRect;
|
webView_.frame = webViewRect;
|
||||||
|
|
||||||
NSString *deviceWidth = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? [NSString stringWithFormat:@"%d", CGRectGetWidth(self.bounds)] : @"device-width";
|
NSString *deviceWidth = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? [NSString stringWithFormat:@"%d", CGRectGetWidth(self.bounds)] : @"device-width";
|
||||||
//BWHockeyLog(@"%@\n%@\%@", PSWebTableViewCellHtmlTemplate, deviceWidth, self.webViewContent);
|
//BWHockeyLog(@"%@\n%@\%@", PSWebTableViewCellHtmlTemplate, deviceWidth, self.webViewContent);
|
||||||
NSString *contentHtml = [NSString stringWithFormat:PSWebTableViewCellHtmlTemplate, deviceWidth, self.webViewContent];
|
NSString *contentHtml = [NSString stringWithFormat:PSWebTableViewCellHtmlTemplate, deviceWidth, self.webViewContent];
|
||||||
[webView_ loadHTMLString:contentHtml baseURL:nil];
|
[webView_ loadHTMLString:contentHtml baseURL:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)showWebView {
|
- (void)showWebView {
|
||||||
webView_.hidden = NO;
|
webView_.hidden = NO;
|
||||||
self.textLabel.text = @"";
|
self.textLabel.text = @"";
|
||||||
[self setNeedsDisplay];
|
[self setNeedsDisplay];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)removeWebView {
|
- (void)removeWebView {
|
||||||
if(webView_) {
|
if(webView_) {
|
||||||
webView_.delegate = nil;
|
webView_.delegate = nil;
|
||||||
[webView_ resignFirstResponder];
|
[webView_ resignFirstResponder];
|
||||||
[webView_ removeFromSuperview];
|
[webView_ removeFromSuperview];
|
||||||
[webView_ release];
|
[webView_ release];
|
||||||
}
|
}
|
||||||
webView_ = nil;
|
webView_ = nil;
|
||||||
[self setNeedsDisplay];
|
[self setNeedsDisplay];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -163,15 +163,15 @@ body { font: 13px 'Helvetica Neue', Helvetica; word-wrap:break-word; padding:8px
|
|||||||
#pragma mark UIWebView
|
#pragma mark UIWebView
|
||||||
|
|
||||||
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
|
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
|
||||||
if(navigationType == UIWebViewNavigationTypeOther)
|
if(navigationType == UIWebViewNavigationTypeOther)
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)webViewDidFinishLoad:(UIWebView *)webView {
|
- (void)webViewDidFinishLoad:(UIWebView *)webView {
|
||||||
if(webViewContent_)
|
if(webViewContent_)
|
||||||
[self showWebView];
|
[self showWebView];
|
||||||
|
|
||||||
CGRect frame = webView_.frame;
|
CGRect frame = webView_.frame;
|
||||||
|
|||||||
@ -87,9 +87,9 @@ CGImageRef CreateGradientImage(int pixelsWide, int pixelsHigh, float fromAlpha,
|
|||||||
- (UIImage *)bw_roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize {
|
- (UIImage *)bw_roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize {
|
||||||
// If the image does not have an alpha layer, add one
|
// If the image does not have an alpha layer, add one
|
||||||
|
|
||||||
UIImage *roundedImage = nil;
|
UIImage *roundedImage = nil;
|
||||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
|
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
|
||||||
BW_IF_IOS4_OR_GREATER(
|
BW_IF_IOS4_OR_GREATER(
|
||||||
UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0); // 0.0 for scale means "correct scale for device's main screen".
|
UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0); // 0.0 for scale means "correct scale for device's main screen".
|
||||||
CGImageRef sourceImg = CGImageCreateWithImageInRect([self CGImage], CGRectMake(0, 0, self.size.width * self.scale, self.size.height * self.scale)); // cropping happens here.
|
CGImageRef sourceImg = CGImageCreateWithImageInRect([self CGImage], CGRectMake(0, 0, self.size.width * self.scale, self.size.height * self.scale)); // cropping happens here.
|
||||||
|
|
||||||
@ -224,20 +224,21 @@ CGImageRef CreateGradientImage(int pixelsWide, int pixelsHigh, float fromAlpha,
|
|||||||
image = UIGraphicsGetImageFromCurrentImageContext();
|
image = UIGraphicsGetImageFromCurrentImageContext();
|
||||||
UIGraphicsEndImageContext();
|
UIGraphicsEndImageContext();
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
// Try older method.
|
// Try older method.
|
||||||
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||||
CGContextRef context = CGBitmapContextCreate(NULL, scaledWidth, scaledHeight, 8, (fitSize.width * 4),
|
CGContextRef context = CGBitmapContextCreate(NULL, scaledWidth, scaledHeight, 8, (fitSize.width * 4),
|
||||||
colorSpace, kCGImageAlphaPremultipliedLast);
|
colorSpace, kCGImageAlphaPremultipliedLast);
|
||||||
CGImageRef sourceImg = CGImageCreateWithImageInRect([self CGImage], sourceRect);
|
CGImageRef sourceImg = CGImageCreateWithImageInRect([self CGImage], sourceRect);
|
||||||
CGContextDrawImage(context, destRect, sourceImg);
|
CGContextDrawImage(context, destRect, sourceImg);
|
||||||
CGImageRelease(sourceImg);
|
CGImageRelease(sourceImg);
|
||||||
CGImageRef finalImage = CGBitmapContextCreateImage(context);
|
CGImageRef finalImage = CGBitmapContextCreateImage(context);
|
||||||
CGContextRelease(context);
|
CGContextRelease(context);
|
||||||
CGColorSpaceRelease(colorSpace);
|
CGColorSpaceRelease(colorSpace);
|
||||||
image = [UIImage imageWithCGImage:finalImage];
|
image = [UIImage imageWithCGImage:finalImage];
|
||||||
CGImageRelease(finalImage);
|
CGImageRelease(finalImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
@ -245,37 +246,37 @@ CGImageRef CreateGradientImage(int pixelsWide, int pixelsHigh, float fromAlpha,
|
|||||||
|
|
||||||
|
|
||||||
CGImageRef CreateGradientImage(int pixelsWide, int pixelsHigh, float fromAlpha, float toAlpha) {
|
CGImageRef CreateGradientImage(int pixelsWide, int pixelsHigh, float fromAlpha, float toAlpha) {
|
||||||
CGImageRef theCGImage = NULL;
|
CGImageRef theCGImage = NULL;
|
||||||
|
|
||||||
// gradient is always black-white and the mask must be in the gray colorspace
|
// gradient is always black-white and the mask must be in the gray colorspace
|
||||||
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
|
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
|
||||||
|
|
||||||
// create the bitmap context
|
// create the bitmap context
|
||||||
CGContextRef gradientBitmapContext = CGBitmapContextCreate(NULL, pixelsWide, pixelsHigh,
|
CGContextRef gradientBitmapContext = CGBitmapContextCreate(NULL, pixelsWide, pixelsHigh,
|
||||||
8, 0, colorSpace, kCGImageAlphaNone);
|
8, 0, colorSpace, kCGImageAlphaNone);
|
||||||
|
|
||||||
// define the start and end grayscale values (with the alpha, even though
|
// define the start and end grayscale values (with the alpha, even though
|
||||||
// our bitmap context doesn't support alpha the gradient requires it)
|
// our bitmap context doesn't support alpha the gradient requires it)
|
||||||
CGFloat colors[] = {toAlpha, 1.0, fromAlpha, 1.0};
|
CGFloat colors[] = {toAlpha, 1.0, fromAlpha, 1.0};
|
||||||
|
|
||||||
// create the CGGradient and then release the gray color space
|
// create the CGGradient and then release the gray color space
|
||||||
CGGradientRef grayScaleGradient = CGGradientCreateWithColorComponents(colorSpace, colors, NULL, 2);
|
CGGradientRef grayScaleGradient = CGGradientCreateWithColorComponents(colorSpace, colors, NULL, 2);
|
||||||
CGColorSpaceRelease(colorSpace);
|
CGColorSpaceRelease(colorSpace);
|
||||||
|
|
||||||
// create the start and end points for the gradient vector (straight down)
|
// create the start and end points for the gradient vector (straight down)
|
||||||
CGPoint gradientEndPoint = CGPointZero;
|
CGPoint gradientEndPoint = CGPointZero;
|
||||||
CGPoint gradientStartPoint = CGPointMake(0, pixelsHigh);
|
CGPoint gradientStartPoint = CGPointMake(0, pixelsHigh);
|
||||||
|
|
||||||
// draw the gradient into the gray bitmap context
|
// draw the gradient into the gray bitmap context
|
||||||
CGContextDrawLinearGradient(gradientBitmapContext, grayScaleGradient, gradientStartPoint,
|
CGContextDrawLinearGradient(gradientBitmapContext, grayScaleGradient, gradientStartPoint,
|
||||||
gradientEndPoint, kCGGradientDrawsAfterEndLocation);
|
gradientEndPoint, kCGGradientDrawsAfterEndLocation);
|
||||||
CGGradientRelease(grayScaleGradient);
|
CGGradientRelease(grayScaleGradient);
|
||||||
|
|
||||||
// convert the context into a CGImageRef and release the context
|
// convert the context into a CGImageRef and release the context
|
||||||
theCGImage = CGBitmapContextCreateImage(gradientBitmapContext);
|
theCGImage = CGBitmapContextCreateImage(gradientBitmapContext);
|
||||||
CGContextRelease(gradientBitmapContext);
|
CGContextRelease(gradientBitmapContext);
|
||||||
|
|
||||||
// return the imageref containing the gradient
|
// return the imageref containing the gradient
|
||||||
return theCGImage;
|
return theCGImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,29 +294,29 @@ CGContextRef MyOpenBitmapContext(int pixelsWide, int pixelsHigh) {
|
|||||||
|
|
||||||
- (UIImage *)bw_reflectedImageWithHeight:(NSUInteger)height fromAlpha:(float)fromAlpha toAlpha:(float)toAlpha {
|
- (UIImage *)bw_reflectedImageWithHeight:(NSUInteger)height fromAlpha:(float)fromAlpha toAlpha:(float)toAlpha {
|
||||||
if(height == 0)
|
if(height == 0)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
// create a bitmap graphics context the size of the image
|
// create a bitmap graphics context the size of the image
|
||||||
CGContextRef mainViewContentContext = MyOpenBitmapContext(self.size.width, height);
|
CGContextRef mainViewContentContext = MyOpenBitmapContext(self.size.width, height);
|
||||||
|
|
||||||
// create a 2 bit CGImage containing a gradient that will be used for masking the
|
// create a 2 bit CGImage containing a gradient that will be used for masking the
|
||||||
// main view content to create the 'fade' of the reflection. The CGImageCreateWithMask
|
// main view content to create the 'fade' of the reflection. The CGImageCreateWithMask
|
||||||
// function will stretch the bitmap image as required, so we can create a 1 pixel wide gradient
|
// function will stretch the bitmap image as required, so we can create a 1 pixel wide gradient
|
||||||
CGImageRef gradientMaskImage = CreateGradientImage(1, height, fromAlpha, toAlpha);
|
CGImageRef gradientMaskImage = CreateGradientImage(1, height, fromAlpha, toAlpha);
|
||||||
|
|
||||||
// create an image by masking the bitmap of the mainView content with the gradient view
|
// create an image by masking the bitmap of the mainView content with the gradient view
|
||||||
// then release the pre-masked content bitmap and the gradient bitmap
|
// then release the pre-masked content bitmap and the gradient bitmap
|
||||||
CGContextClipToMask(mainViewContentContext, CGRectMake(0.0, 0.0, self.size.width, height), gradientMaskImage);
|
CGContextClipToMask(mainViewContentContext, CGRectMake(0.0, 0.0, self.size.width, height), gradientMaskImage);
|
||||||
CGImageRelease(gradientMaskImage);
|
CGImageRelease(gradientMaskImage);
|
||||||
|
|
||||||
// draw the image into the bitmap context
|
// draw the image into the bitmap context
|
||||||
CGContextDrawImage(mainViewContentContext, CGRectMake(0, 0, self.size.width, self.size.height), self.CGImage);
|
CGContextDrawImage(mainViewContentContext, CGRectMake(0, 0, self.size.width, self.size.height), self.CGImage);
|
||||||
|
|
||||||
// convert the finished reflection image to a UIImage
|
// convert the finished reflection image to a UIImage
|
||||||
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); // returns autoreleased
|
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); // returns autoreleased
|
||||||
UIGraphicsEndImageContext();
|
UIGraphicsEndImageContext();
|
||||||
|
|
||||||
return theImage;
|
return theImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)bw_initWithContentsOfResolutionIndependentFile:(NSString *)path {
|
- (id)bw_initWithContentsOfResolutionIndependentFile:(NSString *)path {
|
||||||
@ -342,10 +343,10 @@ CGContextRef MyOpenBitmapContext(int pixelsWide, int pixelsHigh) {
|
|||||||
|
|
||||||
|
|
||||||
+ (UIImage *)bw_imageNamed:(NSString *)imageName bundle:(NSString *)bundleName {
|
+ (UIImage *)bw_imageNamed:(NSString *)imageName bundle:(NSString *)bundleName {
|
||||||
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
|
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
|
||||||
NSString *bundlePath = [resourcePath stringByAppendingPathComponent:bundleName];
|
NSString *bundlePath = [resourcePath stringByAppendingPathComponent:bundleName];
|
||||||
NSString *imagePath = [bundlePath stringByAppendingPathComponent:imageName];
|
NSString *imagePath = [bundlePath stringByAppendingPathComponent:imageName];
|
||||||
return [UIImage bw_imageWithContentsOfResolutionIndependentFile:imagePath];
|
return [UIImage bw_imageWithContentsOfResolutionIndependentFile:imagePath];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user