Skip to content

Commit

Permalink
Make HTTP request for BugzScout
Browse files Browse the repository at this point in the history
  • Loading branch information
kaler committed Aug 5, 2010
1 parent 317fdb8 commit 1650eef
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Classes/CrashLogger.h
Expand Up @@ -38,7 +38,7 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@interface CrashBugzScoutLogger : CrashLogger
{
NSString *url;
NSString *urlString;
NSString *user;
NSString *project;
NSString *area;
Expand All @@ -47,7 +47,7 @@
- (id)initWithURL:(NSString*)aURL user:(NSString*)aUser project:(NSString*)aProject area:(NSString*)aArea;
- (void)sendCrash:(NSDictionary*)crash;

@property (nonatomic, copy) NSString *url;
@property (nonatomic, copy) NSString *urlString;
@property (nonatomic, copy) NSString *user;
@property (nonatomic, copy) NSString *project;
@property (nonatomic, copy) NSString *area;
Expand Down
48 changes: 43 additions & 5 deletions Classes/CrashLogger.m
Expand Up @@ -123,13 +123,13 @@ - (void)mailComposeController:(MFMailComposeViewController*)controller didFinish
#pragma mark -

@implementation CrashBugzScoutLogger
@synthesize url, user, project, area;
@synthesize urlString, user, project, area;

- (id)initWithURL:(NSString*)aUrl user:(NSString *)aUser project:(NSString *)aProject area:(NSString *)aArea
{
if ((self = [super init]))
{
url = [aUrl copy];
urlString = [aUrl copy];
user = [aUser copy];
project = [aProject copy];
area = [aArea copy];
Expand All @@ -140,7 +140,7 @@ - (id)initWithURL:(NSString*)aUrl user:(NSString *)aUser project:(NSString *)aPr

- (void)dealloc
{
[url release];
[urlString release];
[user release];
[project release];
[area release];
Expand All @@ -150,9 +150,47 @@ - (void)dealloc

- (void)sendCrash:(NSDictionary *)crash
{
NSLog(@"CrashBugzScoutLogger sendCrash: %@, %@, %@, %@", self.url, self.user, self.project, self.area);
[self pumpRunLoop];
NSLog(@"CrashBugzScoutLogger sendCrash: %@, %@, %@, %@", self.urlString, self.user, self.project, self.area);

NSURL *url = [NSURL URLWithString:self.urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
NSString *bodyString = [NSString stringWithFormat:
@"<form method=\"post\" action=\" %@ \">"
"<input type=\"text\" value=\"FogBUGZ User Name\" name=\" %@ \">"
"<input type=\"text\" value=\"Existing Project Name\" name=\" %@ \">"
"<input type=\"text\" value=\"Existing Area Name\" name=\" %@ \">"
"<input type=\"text\" value=\"Description\" name=\"Description\">"
"<input type=\"text\" value=\"0\" name=\"ForceNewBug\">"
"<input type=\"text\" value=\"extra info\" name=\"Extra\">"
"<input type=\"text\" value=\"customer@emailaddress.com\" name=\"Email\">"
"<input type=\"text\" value=\"html Default Message\" name=\"ScoutDefaultMessage\">"
"<input type=\"text\" value=\"1\" name=\"FriendlyResponse\">"
"<input type=\"submit\">"
"</form>",
self.urlString, self.user, self.project, self.area];
NSLog(@"Body: %@", bodyString);


NSData *data = [bodyString dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:data];

NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self];
[connection start];

[self pumpRunLoop];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"Connection Did Fail");
self.finishPump = YES;
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"Connection Did Finish Loading");
self.finishPump = YES;
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/RootViewController.m
Expand Up @@ -59,7 +59,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
else
{
[crash sendCrashReportsToBugzScoutURL:@"https://mysite.fogbugz.com/scoutsubmit.asp"
[crash sendCrashReportsToBugzScoutURL:@"https://smartfulstudios.fogbugz.com/scoutsubmit.asp"
withUser:@"Parveen Kaler"
forProject:@"Inbox"
withArea:@"Misc"];
Expand Down

0 comments on commit 1650eef

Please sign in to comment.