Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndereAndi committed Apr 27, 2011
1 parent 0e525a6 commit e97ca00
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions client/iOS/BWQuincyManager.m
Expand Up @@ -94,10 +94,10 @@ - (id) init {
_urlConnection = nil;
_submissionURL = nil;
_responseData = nil;
_appIdentifier = nil;

self.delegate = nil;
self.feedbackActivated = NO;
self.appIdentifier = nil;

NSString *testValue = [[NSUserDefaults standardUserDefaults] stringForKey:kQuincyKitAnalyzerStarted];
if (testValue) {
Expand Down Expand Up @@ -398,7 +398,7 @@ - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName names
else if ([elementName isEqualToString: @"id"]) {
_feedbackRequestID = [_contentOfProperty copy];
} else if ([elementName isEqualToString: @"delay"]) {
_feedbackDelayInterval = [_contentOfProperty intValue];
_feedbackDelayInterval = ([_contentOfProperty floatValue] * 0.01); // we get back ms, but need s
} else if ([elementName isEqualToString: @"status"]) {
_serverResult = [_contentOfProperty intValue];
}
Expand Down Expand Up @@ -726,8 +726,10 @@ - (NSString *)_crashLogStringForReport:(PLCrashReport *)report {
- (void)_checkForFeedbackStatus {
NSMutableURLRequest *request = nil;

request = [NSMutableURLRequest requestWithURL:[NSString stringWithFormat:@"https://beta.hockeyapp.net/api/2/apps/%@/crashes",
[self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@api/2/apps/%@/crashes",
self.submissionURL,
[self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
]
]];

[request setCachePolicy: NSURLRequestReloadIgnoringLocalCacheData];
Expand All @@ -754,8 +756,10 @@ - (void)_postXML:(NSString*)xml toURL:(NSURL*)url {
NSString *boundary = @"----FOO";

if (self.appIdentifier) {
request = [NSMutableURLRequest requestWithURL:[NSString stringWithFormat:@"https://beta.hockeyapp.net/api/2/apps/%@/crashes",
[self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@api/2/apps/%@/crashes",
self.submissionURL,
[self.appIdentifier stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
]
]];
} else {
request = [NSMutableURLRequest requestWithURL:url];
Expand All @@ -771,7 +775,7 @@ - (void)_postXML:(NSString*)xml toURL:(NSURL*)url {

NSMutableData *postBody = [NSMutableData data];
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
if ([self isUsingHockeyApp]) {
if (self.appIdentifier) {
[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]];
} else {
Expand Down Expand Up @@ -834,6 +838,22 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[parser parse];

[parser release];

if ([self isFeedbackActivated]) {
if (self.appIdentifier) {
// only proceed if the server did not report any problem
if (_serverResult == CrashReportStatusQueued) {
// the report is still in the queue
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_checkForFeedbackStatus) object:nil];
[self performSelector:@selector(_checkForFeedbackStatus) withObject:nil afterDelay:_feedbackDelayInterval];
} else {
// we do have a status, show it if needed
[self showCrashStatusMessage];
}
} else {
[self showCrashStatusMessage];
}
}
}

[_responseData release];
Expand All @@ -843,22 +863,6 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(connectionClosed)]) {
[self.delegate connectionClosed];
}

if ([self isFeedbackActivated]) {
if ([self isUsingHockeyApp]) {
// only proceed if the server did not report any problem
if (_serverResult == CrashReportStatusQueued) {
// the report is still in the queue
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_checkForFeedbackStatus) object:nil];
[self performSelector:@selector(_checkForFeedbackStatus) withObject:nil afterDelay:_feedbackDelayInterval];
} else {
// we do have a status, show it if needed
[self showCrashStatusMessage];
}
} else {
[self showCrashStatusMessage];
}
}
}

- (void)reachabilityChanged:(NSNotification *)notification {
Expand Down

0 comments on commit e97ca00

Please sign in to comment.