aboutsummaryrefslogtreecommitdiffstats
path: root/iphone/FixMyStreet/Classes
diff options
context:
space:
mode:
Diffstat (limited to 'iphone/FixMyStreet/Classes')
-rw-r--r--iphone/FixMyStreet/Classes/AboutViewController.h18
-rw-r--r--iphone/FixMyStreet/Classes/AboutViewController.m45
-rw-r--r--iphone/FixMyStreet/Classes/Default.pngbin25657 -> 0 bytes
-rw-r--r--iphone/FixMyStreet/Classes/EditSubjectViewController.h22
-rw-r--r--iphone/FixMyStreet/Classes/EditSubjectViewController.m164
-rw-r--r--iphone/FixMyStreet/Classes/EditingTableViewCell.h16
-rw-r--r--iphone/FixMyStreet/Classes/EditingTableViewCell.m41
-rw-r--r--iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.h48
-rw-r--r--iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.m233
-rw-r--r--iphone/FixMyStreet/Classes/InputTableViewController.h45
-rw-r--r--iphone/FixMyStreet/Classes/InputTableViewController.m359
-rwxr-xr-xiphone/FixMyStreet/Classes/Reachability.h122
-rwxr-xr-xiphone/FixMyStreet/Classes/Reachability.m585
-rw-r--r--iphone/FixMyStreet/Classes/Report.h14
-rw-r--r--iphone/FixMyStreet/Classes/Report.m64
-rw-r--r--iphone/FixMyStreet/Classes/SettingsViewController.h24
-rw-r--r--iphone/FixMyStreet/Classes/SettingsViewController.m214
-rw-r--r--iphone/FixMyStreet/Classes/imageCell.h21
-rw-r--r--iphone/FixMyStreet/Classes/imageCell.m72
-rw-r--r--iphone/FixMyStreet/Classes/mysociety.pngbin4467 -> 0 bytes
20 files changed, 0 insertions, 2107 deletions
diff --git a/iphone/FixMyStreet/Classes/AboutViewController.h b/iphone/FixMyStreet/Classes/AboutViewController.h
deleted file mode 100644
index 21922cd8b..000000000
--- a/iphone/FixMyStreet/Classes/AboutViewController.h
+++ /dev/null
@@ -1,18 +0,0 @@
-//
-// AboutViewController.h
-// FixMyStreet
-//
-// Created by Matthew on 23/10/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-
-@interface AboutViewController : UIViewController {
- IBOutlet UIButton* donateButton;
-}
-
--(IBAction)donate:(id)sender;
-
-@end
diff --git a/iphone/FixMyStreet/Classes/AboutViewController.m b/iphone/FixMyStreet/Classes/AboutViewController.m
deleted file mode 100644
index 8f6e8a228..000000000
--- a/iphone/FixMyStreet/Classes/AboutViewController.m
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// AboutViewController.m
-// FixMyStreet
-//
-// Created by Matthew on 23/10/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import "AboutViewController.h"
-
-@implementation AboutViewController
-
-/*
-// Override initWithNibName:bundle: to load the view using a nib file then perform additional customization that is not appropriate for viewDidLoad.
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
- // Custom initialization
- }
- return self;
-}
-*/
-
-// Implement viewDidLoad to do additional setup after loading the view.
-- (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"About";
- self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
- donateButton.titleLabel.font = [UIFont systemFontOfSize:32];
-}
-
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- // Return YES for supported orientations
- return (interfaceOrientation == UIInterfaceOrientationPortrait);
-}
-
-- (void)dealloc {
- [super dealloc];
-}
-
--(IBAction)donate:(id)sender {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.mysociety.org/donate/"]];
-}
-
-@end
diff --git a/iphone/FixMyStreet/Classes/Default.png b/iphone/FixMyStreet/Classes/Default.png
deleted file mode 100644
index 10143f6ac..000000000
--- a/iphone/FixMyStreet/Classes/Default.png
+++ /dev/null
Binary files differ
diff --git a/iphone/FixMyStreet/Classes/EditSubjectViewController.h b/iphone/FixMyStreet/Classes/EditSubjectViewController.h
deleted file mode 100644
index e998d0fee..000000000
--- a/iphone/FixMyStreet/Classes/EditSubjectViewController.h
+++ /dev/null
@@ -1,22 +0,0 @@
-//
-// EditSubjectViewController.h
-// FixMyStreet
-//
-// Created by Matthew on 01/10/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-@class EditingTableViewCell;
-
-@interface EditSubjectViewController : UITableViewController <UITextFieldDelegate> {
- EditingTableViewCell *cell;
-}
-
-@property (nonatomic, retain) EditingTableViewCell *cell;
-
--(void)setAll:(NSString*)a viewTitle:(NSString*)b placeholder:(NSString*)c keyboardType:(UIKeyboardType)d capitalisation:(UITextAutocapitalizationType)e;
--(void)updateText:(NSString*)text;
-
-@end
diff --git a/iphone/FixMyStreet/Classes/EditSubjectViewController.m b/iphone/FixMyStreet/Classes/EditSubjectViewController.m
deleted file mode 100644
index 614aa7f7b..000000000
--- a/iphone/FixMyStreet/Classes/EditSubjectViewController.m
+++ /dev/null
@@ -1,164 +0,0 @@
-//
-// EditSubjectViewController.m
-// FixMyStreet
-//
-// Created by Matthew on 01/10/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import "EditSubjectViewController.h"
-#import "EditingTableViewCell.h"
-#import "FixMyStreetAppDelegate.h"
-
-@implementation EditSubjectViewController
-
-@synthesize cell;
-
-/*
-- (id)initWithStyle:(UITableViewStyle)style {
- // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- if (self = [super initWithStyle:style]) {
- }
- return self;
-}
-*/
-
--(void)setAll:(NSString*)a viewTitle:(NSString*)b placeholder:(NSString*)c keyboardType:(UIKeyboardType)d capitalisation:(UITextAutocapitalizationType)e {
- cell = [[EditingTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"EditingCell"];
- cell.textField.delegate = self;
- cell.textField.placeholder = c;
- self.title = b;
- if (a) cell.textField.text = a;
- cell.textField.keyboardType = d;
- if (b == @"Edit name" || b == @"Edit email") {
- cell.textField.autocorrectionType = UITextAutocorrectionTypeNo;
- }
- cell.textField.autocapitalizationType = e;
-}
-
-// Implement viewDidLoad to do additional setup after loading the view.
-- (void)viewDidLoad {
- [super viewDidLoad];
- self.tableView.sectionHeaderHeight = 27.0;
- self.tableView.sectionFooterHeight = 0.0;
-// self.title = viewTitle;
-}
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- if (cell.textField.placeholder == @"Subject") {
- return 2;
- }
- return 1;
-}
-
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 1;
-}
-
-- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.section == 1) {
- return 54.0;
- }
- return 44.0;
-}
-
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.section == 1) {
- static NSString *CellIdentifier = @"InfoCell";
- UITableViewCell *infoCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (infoCell == nil) {
- infoCell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
- UITextView *blurb = [[UITextView alloc] initWithFrame:CGRectMake(10, 0, 280, 44)];
- blurb.font = [UIFont italicSystemFontOfSize:14];
- blurb.textAlignment = UITextAlignmentCenter;
- blurb.editable = NO;
- blurb.text = @"You can provide more details\nlater on at the website";
- [infoCell.contentView addSubview:blurb];
- [blurb release];
- }
- return infoCell;
- }
-
- return cell;
-}
-
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:NO];
- [cell.textField becomeFirstResponder];
-}
-
-- (void)viewWillAppear:(BOOL)animated {
- //[super viewWillAppear:animated];
- [cell.textField becomeFirstResponder];
-}
-
-/*
-- (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
-}
-*/
-
-- (void)viewWillDisappear:(BOOL)animated {
- // On 2.0 this produces same effect as clicking Done, but not in 2.1?
- [cell.textField resignFirstResponder];
-}
-
-/*
-- (void)viewDidDisappear:(BOOL)animated {
-}
-*/
-/*
-- (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
-}
-*/
-
-- (void)dealloc {
- [cell release];
- [super dealloc];
-}
-
-
--(void)updateText:(NSString*)text {
- FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
- // This is yucky, but I can't think of a better way that wouldn't just waste time.
- NSString* placeholder = cell.textField.placeholder;
- if (placeholder == @"Subject") {
- if (text.length) {
- delegate.subject = text;
- } else {
- delegate.subject = nil;
- }
- } else if (placeholder == @"Your name") {
- if (text.length) {
- delegate.name = text;
- } else {
- delegate.name = nil;
- }
- } else if (placeholder == @"Your email") {
- if (text.length) {
- delegate.email = text;
- } else {
- delegate.email = nil;
- }
- } else if (placeholder == @"Your phone number") {
- if (text.length) {
- delegate.phone = text;
- } else {
- delegate.phone = nil;
- }
- }
- [self.navigationController popViewControllerAnimated:YES];
-}
-
--(BOOL)textFieldShouldReturn:(UITextField*)theTextField {
- //if (theTextField == subjectTextField) {
- [theTextField resignFirstResponder];
- [self updateText:theTextField.text];
- //}
- return YES;
-}
-
-@end
-
diff --git a/iphone/FixMyStreet/Classes/EditingTableViewCell.h b/iphone/FixMyStreet/Classes/EditingTableViewCell.h
deleted file mode 100644
index 812968821..000000000
--- a/iphone/FixMyStreet/Classes/EditingTableViewCell.h
+++ /dev/null
@@ -1,16 +0,0 @@
-//
-// EditingTableViewCell.h
-// FixMyStreet
-//
-// Created by Matthew on 20/10/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-@interface EditingTableViewCell : UITableViewCell {
- UITextField *textField;
-}
-@property (nonatomic, retain) UITextField *textField;
-
-@end
diff --git a/iphone/FixMyStreet/Classes/EditingTableViewCell.m b/iphone/FixMyStreet/Classes/EditingTableViewCell.m
deleted file mode 100644
index 04f9b2fa0..000000000
--- a/iphone/FixMyStreet/Classes/EditingTableViewCell.m
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// EditingTableViewCell.m
-// FixMyStreet
-//
-// Created by Matthew on 20/10/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import "EditingTableViewCell.h"
-
-@implementation EditingTableViewCell
-
-@synthesize textField;
-
-- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
- textField = [[UITextField alloc] initWithFrame:CGRectZero];
- textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
- textField.font = [UIFont systemFontOfSize:20];
- textField.clearButtonMode = UITextFieldViewModeWhileEditing;
- textField.returnKeyType = UIReturnKeyDone;
- [self addSubview:textField];
- }
- return self;
-}
-
--(void)layoutSubviews {
- textField.frame = CGRectInset(self.contentView.bounds, 20, 0);
-}
-
-- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
-}
-
-- (void)dealloc {
- [textField release];
- [super dealloc];
-}
-
-@end
diff --git a/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.h b/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.h
deleted file mode 100644
index 048587695..000000000
--- a/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.h
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// FixMyStreetAppDelegate.h
-// FixMyStreet
-//
-// Created by Matthew on 25/09/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-@class InputTableViewController;
-
-@interface FixMyStreetAppDelegate : NSObject <UIApplicationDelegate> {
- UIWindow *window;
-// UIViewController *viewController;
- UINavigationController *navigationController;
-
- // The report currently being entered.
- NSData* image;
-
- NSString* latitude;
- NSString* longitude;
- NSString* subject;
-
- NSString* name;
- NSString* email;
- NSString* phone;
-
- UIView *uploading;
- NSMutableData* returnData;
-}
-
-@property (nonatomic, retain) IBOutlet UIWindow *window;
-@property (nonatomic, retain) UINavigationController *navigationController;
-//@property (nonatomic, retain) IBOutlet UIViewController *viewController;
-
-@property (nonatomic, retain) NSData* image;
-@property (nonatomic, retain) NSString* latitude;
-@property (nonatomic, retain) NSString* longitude;
-@property (nonatomic, retain) NSString* subject;
-@property (nonatomic, retain) NSString* name;
-@property (nonatomic, retain) NSString* email;
-@property (nonatomic, retain) NSString* phone;
-
--(void)uploadReport;
-
-@end
-
diff --git a/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.m b/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.m
deleted file mode 100644
index aa9b99bb5..000000000
--- a/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.m
+++ /dev/null
@@ -1,233 +0,0 @@
-//
-// FixMyStreetAppDelegate.m
-// FixMyStreet
-//
-// Created by Matthew on 25/09/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import "FixMyStreetAppDelegate.h"
-#import "InputTableViewController.h"
-#import "Reachability.h"
-
-@implementation FixMyStreetAppDelegate
-
-@synthesize window, navigationController; //, viewController;
-@synthesize image, latitude, longitude, subject, name, email, phone;
-
-- (void)applicationDidFinishLaunching:(UIApplication *)application {
- InputTableViewController *inputTableViewController = [[InputTableViewController alloc] initWithNibName:@"MainViewController" bundle:[NSBundle mainBundle]];
-// InputTableViewController *inputTableViewController = [[InputTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
- //RootViewController *rootViewController = [[RootViewController alloc] i
- // So we had our root view in a nib file, but we're creating our navigation controller programmatically. Ah well.
- UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:inputTableViewController];
-// UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
- self.navigationController = aNavigationController;
- [aNavigationController release];
- [inputTableViewController release];
-// [rootViewController release];
-
- // NSMutableArray *tempMutableCopy = [[[NSUserDefaults standardUserDefaults] objectForKey:kRestoreLocationKey] mutableCopy];
- name = [[NSUserDefaults standardUserDefaults] stringForKey:@"Name"];
- email = [[NSUserDefaults standardUserDefaults] stringForKey:@"Email"];
- phone = [[NSUserDefaults standardUserDefaults] stringForKey:@"Phone"];
- subject = [[NSUserDefaults standardUserDefaults] stringForKey:@"Subject"];
-
- image = [[NSUserDefaults standardUserDefaults] objectForKey:@"Image"];
-// NSData *imageData = [[[NSUserDefaults standardUserDefaults] objectForKey:@"Image"] mutableCopy];
-// if (imageData != nil)
-// image = (UIImage *)[NSKeyedUnarchiver unarchiveObjectWithData:imageData];
-// [imageData release];
-
- latitude = [[NSUserDefaults standardUserDefaults] stringForKey:@"Latitude"];
- longitude = [[NSUserDefaults standardUserDefaults] stringForKey:@"Longitude"];
-// NSData *locationData = [[NSUserDefaults standardUserDefaults] objectForKey:@"Location"];
-// if (locationData != nil)
-// location = (CLLocation *)[NSUnarchiver unarchiveObjectWithData:locationData];
-// [locationData release];
-
- [window addSubview:[navigationController view]];
- [window makeKeyAndVisible];
-
-// NSArray *keys = [NSArray arrayWithObjects:@"Name", @"Email", @"Phone", nil];
-// NSArray *values = [NSArray arrayWithObjects:name, email, phone, nil];
-// NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:values forKeys:keys];
-// [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
-// [[NSUserDefaults standardUserDefaults] synchronize];
-// [keys release];
-// [values release];
-// [dictionary release];
-}
-
-- (void)dealloc {
- [window release];
- [navigationController release];
-// [viewController release];
- [image release];
- [latitude release];
- [longitude release];
- [subject release];
- [name release];
- [email release];
- [phone release];
- [super dealloc];
-}
-
-- (void)applicationWillTerminate:(UIApplication *)application {
- // Save state in case they're just in the middle of a phone call...
- [[NSUserDefaults standardUserDefaults] setObject:name forKey:@"Name"];
- [[NSUserDefaults standardUserDefaults] setObject:email forKey:@"Email"];
- [[NSUserDefaults standardUserDefaults] setObject:phone forKey:@"Phone"];
- [[NSUserDefaults standardUserDefaults] setObject:subject forKey:@"Subject"];
-
-// XXX image crashes (restarting app. still has image showing?! and then quitting crashes, either way)
-// Location just doesn't seem to work
-
-// if (image) {
-// NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
-// NSString *imageFile = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"saved.image"];
-// [NSKeyedArchiver archiveRootObject:image toFile:imageFile];
-// }
-// NSData *imageData = [NSKeyedArchiver archivedDataWithRootObject:image];
-// [[NSUserDefaults standardUserDefaults] setObject:imageData forKey:@"Image"];
-// [imageData release];
- [[NSUserDefaults standardUserDefaults] setObject:image forKey:@"Image"];
-
- [[NSUserDefaults standardUserDefaults] setObject:latitude forKey:@"Latitude"];
- [[NSUserDefaults standardUserDefaults] setObject:longitude forKey:@"Longitude"];
-// NSData *locationData = [NSKeyedArchiver archivedDataWithRootObject:location];
-// [[NSUserDefaults standardUserDefaults] setObject:locationData forKey:@"Location"];
-// [locationData release];
-
- [[NSUserDefaults standardUserDefaults] synchronize];
-}
-
-// Report stuff
--(void)uploadReport {
- // Check internet connection status
- NetworkStatus internetConnectionStatus = [[Reachability sharedReachability] internetConnectionStatus];
- if (internetConnectionStatus == NotReachable) {
- UIAlertView *v = [[UIAlertView alloc] initWithTitle:@"Reporting failed" message:@"You need to be connected to the internet to report a problem." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
- [v show];
- [v release];
- return;
- }
-
- [[MyCLController sharedInstance] stopUpdatingLocation];
- [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
-
- uploading = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
- UIColor *bg = [[UIColor alloc] initWithRed:0 green:0 blue:0 alpha:0.5];
- uploading.backgroundColor = bg;
- [bg release];
- UIActivityIndicatorView *spinny = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
- spinny.center = CGPointMake(160, 160);
- [uploading addSubview:spinny];
- [spinny startAnimating];
- [self.navigationController.view addSubview:uploading];
- [spinny release];
-
- // Get the phone's unique ID
- UIDevice *dev = [UIDevice currentDevice];
- NSString *uniqueId = dev.uniqueIdentifier;
-
- NSString *urlString = @"http://matthew.fixmystreet.com/import";
- NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
- [request setURL:[NSURL URLWithString: urlString]];
- [request setHTTPMethod: @"POST"];
-
- NSString *stringBoundary = @"0xMyLovelyBoundary";
- NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",stringBoundary];
- [request addValue:contentType forHTTPHeaderField: @"Content-Type"];
-
- //setting up the body:
- NSMutableData *postBody = [NSMutableData data];
-
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"service\"\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[@"iPhone" dataUsingEncoding:NSASCIIStringEncoding]];
-
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"phone_id\"\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[uniqueId dataUsingEncoding:NSASCIIStringEncoding]];
-
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"subject\"\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[subject dataUsingEncoding:NSASCIIStringEncoding]];
-
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"name\"\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[name dataUsingEncoding:NSASCIIStringEncoding]];
-
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"email\"\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[email dataUsingEncoding:NSASCIIStringEncoding]];
-
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"phone\"\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[phone dataUsingEncoding:NSASCIIStringEncoding]];
-
- if (latitude) {
-// NSString* latitude = [NSString stringWithFormat:@"%f", location.coordinates.latitude];
-// NSString* longitude = [NSString stringWithFormat:@"%f", location.coordinates.longitude];
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"lat\"\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[latitude dataUsingEncoding:NSASCIIStringEncoding]];
-
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"lon\"\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[longitude dataUsingEncoding:NSASCIIStringEncoding]];
- }
-
- if (image) {
-// NSData *imageData = UIImageJPEGRepresentation(image, 0.8);
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"photo\"; filename=\"from_phone.jpeg\"\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[[NSString stringWithString:@"Content-Type: image/jpeg\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:[[NSString stringWithString:@"Content-Transfer-Encoding: binary\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
- [postBody appendData:image];
- }
-
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]];
-
- [request setHTTPBody: postBody];
-
- returnData = [[NSMutableData alloc] init];
- [NSURLConnection connectionWithRequest:request delegate:self];
-// NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
-}
-
-- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
- [returnData appendData:data];
-}
-
--(void)connectionDidFinishLoading:(NSURLConnection *)connection {
- [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
- [uploading removeFromSuperview];
-
- NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding];
-
- if ([returnString isEqualToString:@"SUCCESS"]) {
- subject = nil;
- latitude = nil;
- longitude = nil;
- self.image = nil;
- [(InputTableViewController*)self.navigationController.visibleViewController reportUploaded:YES];
- UIAlertView *v = [[UIAlertView alloc] initWithTitle:@"Your report has been received" message:@"Check your email for the next step" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
- [v show];
- [v release];
- } else {
- // Pop up alert box with return error(s)
- NSArray *errors = [returnString componentsSeparatedByString:@"ERROR:"];
- NSString *errorString = [[NSString alloc] init];
- for (int i=1; i<[errors count]; i++) {
- NSString *error = [errors objectAtIndex:i];
- errorString = [errorString stringByAppendingFormat:@"\xE2\x80\xA2 %@", error];
- }
- UIAlertView *v = [[UIAlertView alloc] initWithTitle:@"Upload failed" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
- [v show];
- [v release];
- }
-}
-
-@end
diff --git a/iphone/FixMyStreet/Classes/InputTableViewController.h b/iphone/FixMyStreet/Classes/InputTableViewController.h
deleted file mode 100644
index f902c4017..000000000
--- a/iphone/FixMyStreet/Classes/InputTableViewController.h
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// InputTableViewController.h
-// FixMyStreet
-//
-// Created by Matthew on 26/09/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-#import "MyCLController.h"
-
-@interface InputTableViewController : UIViewController <UINavigationControllerDelegate,UIImagePickerControllerDelegate,MyCLControllerDelegate> {
- IBOutlet UIImageView* imageView;
- IBOutlet UITableView* actionsToDoView;
- IBOutlet UIButton* settingsButton;
- UIBarButtonItem* backButton;
-
- // Not sure what I made these for
- UITableViewCell* actionTakePhotoCell;
- UITableViewCell* actionFetchLocationCell;
- UITableViewCell* actionSubjectCell;
-
- UILabel* subjectLabel;
- UILabel* subjectContent;
-}
-
--(void)enableSubmissionButton;
--(void)uploadReport;
--(void)reportUploaded:(BOOL)success;
-
--(IBAction)addPhoto:(id) sender;
--(IBAction)gotoSettings:(id)sender firstTime:(BOOL)firstTime;
--(IBAction)gotoAbout:(id)sender;
-
-// UIImagePickerControllerDelegate
-- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo;
-- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;
-
--(BOOL)startLocation;
-
-//MyCLControllerDelegate
--(void)newLocationUpdate:(CLLocation *)location;
--(void)newLocationError:(NSString *)text;
-
-@end
diff --git a/iphone/FixMyStreet/Classes/InputTableViewController.m b/iphone/FixMyStreet/Classes/InputTableViewController.m
deleted file mode 100644
index 7d336e115..000000000
--- a/iphone/FixMyStreet/Classes/InputTableViewController.m
+++ /dev/null
@@ -1,359 +0,0 @@
-//
-// InputTableViewController.m
-// FixMyStreet
-//
-// Created by Matthew on 26/09/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import "InputTableViewController.h"
-#import "SettingsViewController.h"
-#import "FixMyStreetAppDelegate.h"
-#import "EditSubjectViewController.h"
-#import "AboutViewController.h"
-#import "Reachability.h"
-
-@implementation InputTableViewController
-
-//@synthesize image;
-//@synthesize imagCell;
-//@synthesize reportSubject;
-
-- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle {
- if (self = [super initWithNibName:nibName bundle:nibBundle]) {
- self.title = @"FixMyStreet";
- }
- return self;
-}
-
-/*
-- (id)initWithStyle:(UITableViewStyle)style {
- // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- if (self = [super initWithStyle:style]) {
- }
- return self;
-}
-*/
-
-- (void)viewWillAppear:(BOOL)animated {
- [self enableSubmissionButton];
-}
-
-// Implement viewDidLoad to do additional setup after loading the view.
-- (void)viewDidLoad {
- [super viewDidLoad];
-
- settingsButton.frame = CGRectMake(255, 350, 72, 73);
-
- backButton = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonSystemItemCancel target:nil action:nil];
- self.navigationItem.backBarButtonItem = backButton;
-
- UIBarButtonItem* rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Report" style:UIBarButtonItemStyleDone target:self action:@selector(uploadReport) ];
- rightBarButtonItem.enabled = NO;
- self.navigationItem.rightBarButtonItem = rightBarButtonItem;
- [rightBarButtonItem release];
-
- // Let's start trying to find our location...
- [MyCLController sharedInstance].delegate = self;
- [self startLocation];
-
- FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
- if (delegate.image) {
- UIImage *newImage = [[UIImage alloc] initWithData:delegate.image];
- imageView.image = newImage;
- [newImage release];
- }
-
-}
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
- if (delegate.name || delegate.email || delegate.phone)
- return 4;
- return 3;
-}
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 1;
-}
-
--(void)enableSubmissionButton {
- [actionsToDoView reloadData];
- FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
- if (delegate.image && delegate.latitude && delegate.subject && delegate.subject.length) {
- self.navigationItem.rightBarButtonItem.enabled = YES;
- } else {
- self.navigationItem.rightBarButtonItem.enabled = NO;
- }
-}
-
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- static NSString *CellIdentifier;
- UITableViewCell *cell;
- FixMyStreetAppDelegate* delegate = [[UIApplication sharedApplication] delegate];
-
- // Possible editing of subject within main view (I think I prefer it as is)
- // And possible display of selected image within cell somewhere/somehow (I like how Contacts does it, but haven't
- // managed that so far
-
- if (indexPath.section == 1) {
- CellIdentifier = @"CellText";
- cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- //CGRect frame = CGRectMake(0, 0, 250, 44);
- cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
- //cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- //UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(1.0, 1.0, 250, 44)];
- //textField.placeholder = @"Subject";
- // [textField addTarget:self action:nil forControlEvents:UIControlEventValueChanged];
- //cell.accessoryView = textField;
- //[textField release];
- }
- } else {
- /* if (indexPath.section == 0) {
- CellIdentifier = @"CellImage";
- cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[imageCell alloc] initWithFrame:CGRectMake(0, 0, 400, 44) reuseIdentifier:CellIdentifier] autorelease];
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- }
- } else { */
-
- CellIdentifier = @"Cell";
- cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- }
-
- }
-
- if (indexPath.section == 0) {
- if (delegate.image) {
- cell.accessoryType = UITableViewCellAccessoryCheckmark;
- } else {
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- }
- cell.textLabel.text = @"Take photo";
- actionTakePhotoCell = cell;
- } else if (indexPath.section == 2) {
- if (delegate.latitude) {
- cell.accessoryView = nil;
- cell.accessoryType = UITableViewCellAccessoryCheckmark;
- } else if ([MyCLController sharedInstance].updating) {
- UIActivityIndicatorView* activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
- [activityView startAnimating];
- cell.accessoryView = activityView;
- [activityView release];
- } else {
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- }
- cell.textLabel.text = @"Fetch location";
- actionFetchLocationCell = cell;
- } else if (indexPath.section == 1) {
- if (delegate.subject && delegate.subject.length) {
- if (!subjectLabel) {
- subjectLabel = [[UILabel alloc] initWithFrame:CGRectMake(10,0,70,40)];
- subjectLabel.font = [UIFont boldSystemFontOfSize:17];
- subjectLabel.text = @"Subject:";
- [cell.contentView addSubview:subjectLabel];
- }
- subjectLabel.hidden = NO;
- if (!subjectContent) {
- subjectContent = [[UILabel alloc] initWithFrame:CGRectMake(80,0,190,40)];
- subjectContent.font = [UIFont systemFontOfSize:17];
- [cell.contentView addSubview:subjectContent];
- }
- cell.textLabel.text = nil;
- subjectContent.text = delegate.subject;
- subjectContent.hidden = NO;
- cell.accessoryType = UITableViewCellAccessoryCheckmark;
- } else {
- subjectContent.hidden = YES;
- subjectLabel.hidden = YES;
- cell.textLabel.text = @"Short summary of problem";
- cell.textLabel.textColor = [UIColor grayColor];
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- }
- actionSubjectCell = cell;
- } else if (indexPath.section == 3) {
- if (delegate.name && delegate.name.length && delegate.email && delegate.email.length) {
- cell.accessoryType = UITableViewCellAccessoryCheckmark;
- } else {
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- }
- cell.textLabel.text = @"Your details";
- } else {
- cell.textLabel.text = @"Eh?";
- }
- return cell;
-}
-
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- if (indexPath.section == 0) {
- [self addPhoto:nil];
- } else if (indexPath.section == 2) {
- if ([self startLocation]) {
- UIActivityIndicatorView* activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
- [activityView startAnimating];
- actionFetchLocationCell.accessoryView = activityView;
- [activityView release];
- }
- } else if (indexPath.section == 1) {
- FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
- EditSubjectViewController* editSubjectViewController = [[EditSubjectViewController alloc] initWithNibName:@"EditSubjectView" bundle:nil];
- [editSubjectViewController setAll:delegate.subject viewTitle:@"Edit subject" placeholder:@"Subject" keyboardType:UIKeyboardTypeDefault capitalisation:UITextAutocapitalizationTypeSentences];
- [self.navigationController pushViewController:editSubjectViewController animated:YES];
- [editSubjectViewController release];
- } else if (indexPath.section == 3) {
- [self gotoSettings:nil firstTime:NO];
- }
-}
-
--(IBAction)addPhoto:(id) sender {
- BOOL cameraAvailable = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
- BOOL photosAvailable = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary];
- if (!cameraAvailable && !photosAvailable) {
- UITableViewCell *cell = [actionsToDoView cellForRowAtIndexPath:0]; // XXX
- cell.textLabel.text = @"No photo mechanism available";
- return;
- }
- UIImagePickerController* picker = [[UIImagePickerController alloc] init];
- if (cameraAvailable) {
- picker.sourceType = UIImagePickerControllerSourceTypeCamera;
- } else {
- picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- }
- picker.delegate = self;
- picker.allowsImageEditing = NO;
- [self presentModalViewController:picker animated:YES];
-}
-
-- (void)viewDidAppear:(BOOL)animated {
- backButton.title = @"Cancel";
-}
-
-/*
-- (void)viewWillDisappear:(BOOL)animated {
-}
-*/
-/*
-- (void)viewDidDisappear:(BOOL)animated {
-}
-*/
-/*
-- (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
-}
-*/
-
-// Check this, I can't remember if you need to release nib things.
-- (void)dealloc {
- [imageView release];
- [actionTakePhotoCell release];
- [actionFetchLocationCell release];
- [actionSubjectCell release];
- [actionsToDoView release];
- [settingsButton release];
- [backButton release];
- [subjectLabel release];
- [subjectContent release];
- [super dealloc];
-}
-
-
-// UIImagePickerControllerDelegate prototype
-
-- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)newImage editingInfo:(NSDictionary *)editingInfo {
- FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
- NSData *imageData = UIImageJPEGRepresentation(newImage, 0.8);
- delegate.image = imageData;
-
- imageView.image = newImage;
-
- [[picker parentViewController] dismissModalViewControllerAnimated:YES];
- [picker release];
-}
-
-- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
- [[picker parentViewController] dismissModalViewControllerAnimated:YES];
- [picker release];
-}
-
-// MyCLControllerDelegate and related
-
--(BOOL)startLocation {
- NetworkStatus internetConnectionStatus = [[Reachability sharedReachability] internetConnectionStatus];
- if (internetConnectionStatus == NotReachable) {
- UIAlertView *v = [[UIAlertView alloc] initWithTitle:@"Location required" message:@"FixMyStreet needs some sort of connection in order to find your location." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
- [v show];
- [v release];
- return FALSE;
- } else {
- [[MyCLController sharedInstance] startUpdatingLocation];
- return TRUE;
- }
-}
-
--(void)newLocationUpdate:(CLLocation *)location {
- //UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hey" message:text delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
- //[alert show];
- //[alert release];
-
- FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
-// delegate.location = location;
- delegate.latitude = [NSString stringWithFormat:@"%f", location.coordinate.latitude];
- delegate.longitude = [NSString stringWithFormat:@"%f", location.coordinate.longitude];
-
- [self enableSubmissionButton];
-}
-
--(void)newLocationError:(NSString *)text {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Location required" message:text delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
- [alert show];
- [alert release];
- [self enableSubmissionButton];
-}
-
-// Buttons
-
-// I realise this flips the navbar too, but can't seem to do it nicely with a container parent, and not really that important!
--(IBAction)gotoAbout:(id)sender {
- backButton.title = @"Back";
- AboutViewController* aboutViewController = [[AboutViewController alloc] initWithNibName:@"AboutView" bundle:nil];
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration: 0.75];
- [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:YES];
- [self.navigationController pushViewController:aboutViewController animated:NO];
- [UIView commitAnimations];
- [aboutViewController release];
-}
-
--(IBAction)gotoSettings:(id)sender firstTime:(BOOL)firstTime {
- backButton.title = @"Done";
- SettingsViewController* settingsViewController = [[SettingsViewController alloc] initWithStyle:UITableViewStyleGrouped];
- if (firstTime)
- settingsViewController.firstTime = firstTime;
- [self.navigationController pushViewController:settingsViewController animated:YES];
- [settingsViewController release];
-}
-
--(void)uploadReport {
- FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
- if (!delegate.name || !delegate.email) {
- [self gotoSettings:nil firstTime:YES];
- } else {
- [delegate uploadReport];
- }
-}
-
--(void)reportUploaded:(BOOL)success {
- if (success)
- imageView.image = nil;
- [self enableSubmissionButton];
-}
-
-@end
-
diff --git a/iphone/FixMyStreet/Classes/Reachability.h b/iphone/FixMyStreet/Classes/Reachability.h
deleted file mode 100755
index 18beaea3e..000000000
--- a/iphone/FixMyStreet/Classes/Reachability.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
-
-File: Reachability.h
-Abstract: SystemConfiguration framework wrapper.
-
-Version: 1.5
-
-Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
-("Apple") in consideration of your agreement to the following terms, and your
-use, installation, modification or redistribution of this Apple software
-constitutes acceptance of these terms. If you do not agree with these terms,
-please do not use, install, modify or redistribute this Apple software.
-
-In consideration of your agreement to abide by the following terms, and subject
-to these terms, Apple grants you a personal, non-exclusive license, under
-Apple's copyrights in this original Apple software (the "Apple Software"), to
-use, reproduce, modify and redistribute the Apple Software, with or without
-modifications, in source and/or binary forms; provided that if you redistribute
-the Apple Software in its entirety and without modifications, you must retain
-this notice and the following text and disclaimers in all such redistributions
-of the Apple Software.
-Neither the name, trademarks, service marks or logos of Apple Inc. may be used
-to endorse or promote products derived from the Apple Software without specific
-prior written permission from Apple. Except as expressly stated in this notice,
-no other rights or licenses, express or implied, are granted by Apple herein,
-including but not limited to any patent rights that may be infringed by your
-derivative works or by other works in which the Apple Software may be
-incorporated.
-
-The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
-WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
-WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
-COMBINATION WITH YOUR PRODUCTS.
-
-IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
-DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
-CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
-APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-Copyright (C) 2008 Apple Inc. All Rights Reserved.
-
-*/
-
-#import <UIKit/UIKit.h>
-#import <SystemConfiguration/SystemConfiguration.h>
-
-@class Reachability;
-
-@interface Reachability : NSObject {
-
-@private
- BOOL _networkStatusNotificationsEnabled;
-
- NSString *_hostName;
- NSString *_address;
-
- NSMutableDictionary *_reachabilityQueries;
-}
-
-/*
- An enumeration that defines the return values of the network state
- of the device.
- */
-typedef enum {
- NotReachable = 0,
- ReachableViaCarrierDataNetwork,
- ReachableViaWiFiNetwork
-} NetworkStatus;
-
-
-// Set to YES to register for changes in network status. Otherwise reachability queries
-// will be handled synchronously.
-@property BOOL networkStatusNotificationsEnabled;
-// The remote host whose reachability will be queried.
-// Either this or 'addressName' must be set.
-@property (nonatomic, retain) NSString *hostName;
-// The IP address of the remote host whose reachability will be queried.
-// Either this or 'hostName' must be set.
-@property (nonatomic, retain) NSString *address;
-// A cache of ReachabilityQuery objects, which encapsulate a SCNetworkReachabilityRef, a host or address, and a run loop. The keys are host names or addresses.
-@property (nonatomic, assign) NSMutableDictionary *reachabilityQueries;
-
-// This class is intended to be used as a singleton.
-+ (Reachability *)sharedReachability;
-
-// Is self.hostName is not nil, determines its reachability.
-// If self.hostName is nil and self.address is not nil, determines the reachability of self.address.
-- (NetworkStatus)remoteHostStatus;
-// Is the device able to communicate with Internet hosts? If so, through which network interface?
-- (NetworkStatus)internetConnectionStatus;
-// Is the device able to communicate with hosts on the local WiFi network? (Typically these are Bonjour hosts).
-- (NetworkStatus)localWiFiConnectionStatus;
-
-/*
- When reachability change notifications are posted, the callback method 'ReachabilityCallback' is called
- and posts a notification that the client application can observe to learn about changes.
- */
-static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info);
-
-@end
-
-@interface ReachabilityQuery : NSObject
-{
-@private
- SCNetworkReachabilityRef _reachabilityRef;
- CFMutableArrayRef _runLoops;
- NSString *_hostNameOrAddress;
-}
-// Keep around each network reachability query object so that we can
-// register for updates from those objects.
-@property (nonatomic) SCNetworkReachabilityRef reachabilityRef;
-@property (nonatomic, retain) NSString *hostNameOrAddress;
-@property (nonatomic) CFMutableArrayRef runLoops;
-
-- (void)scheduleOnRunLoop:(NSRunLoop *)inRunLoop;
-
-@end
-
diff --git a/iphone/FixMyStreet/Classes/Reachability.m b/iphone/FixMyStreet/Classes/Reachability.m
deleted file mode 100755
index c1f159c55..000000000
--- a/iphone/FixMyStreet/Classes/Reachability.m
+++ /dev/null
@@ -1,585 +0,0 @@
-/*
-
-File: Reachability.m
-Abstract: SystemConfiguration framework wrapper.
-
-Version: 1.5
-
-Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
-("Apple") in consideration of your agreement to the following terms, and your
-use, installation, modification or redistribution of this Apple software
-constitutes acceptance of these terms. If you do not agree with these terms,
-please do not use, install, modify or redistribute this Apple software.
-
-In consideration of your agreement to abide by the following terms, and subject
-to these terms, Apple grants you a personal, non-exclusive license, under
-Apple's copyrights in this original Apple software (the "Apple Software"), to
-use, reproduce, modify and redistribute the Apple Software, with or without
-modifications, in source and/or binary forms; provided that if you redistribute
-the Apple Software in its entirety and without modifications, you must retain
-this notice and the following text and disclaimers in all such redistributions
-of the Apple Software.
-Neither the name, trademarks, service marks or logos of Apple Inc. may be used
-to endorse or promote products derived from the Apple Software without specific
-prior written permission from Apple. Except as expressly stated in this notice,
-no other rights or licenses, express or implied, are granted by Apple herein,
-including but not limited to any patent rights that may be infringed by your
-derivative works or by other works in which the Apple Software may be
-incorporated.
-
-The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
-WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
-WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
-COMBINATION WITH YOUR PRODUCTS.
-
-IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
-DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
-CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
-APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-Copyright (C) 2008 Apple Inc. All Rights Reserved.
-
-*/
-
-#import <sys/socket.h>
-#import <netinet/in.h>
-#import <netinet6/in6.h>
-#import <arpa/inet.h>
-#import <ifaddrs.h>
-#include <netdb.h>
-
-#import "Reachability.h"
-#import <SystemConfiguration/SCNetworkReachability.h>
-
-static NSString *kLinkLocalAddressKey = @"169.254.0.0";
-static NSString *kDefaultRouteKey = @"0.0.0.0";
-
-static Reachability *_sharedReachability;
-
-// A class extension that declares internal methods for this class.
-@interface Reachability()
-- (BOOL)isAdHocWiFiNetworkAvailableFlags:(SCNetworkReachabilityFlags *)outFlags;
-- (BOOL)isNetworkAvailableFlags:(SCNetworkReachabilityFlags *)outFlags;
-- (BOOL)isReachableWithoutRequiringConnection:(SCNetworkReachabilityFlags)flags;
-- (SCNetworkReachabilityRef)reachabilityRefForHostName:(NSString *)hostName;
-- (SCNetworkReachabilityRef)reachabilityRefForAddress:(NSString *)address;
-- (BOOL)addressFromString:(NSString *)IPAddress address:(struct sockaddr_in *)outAddress;
-- (void)stopListeningForReachabilityChanges;
-@end
-
-@implementation Reachability
-
-@synthesize networkStatusNotificationsEnabled = _networkStatusNotificationsEnabled;
-@synthesize hostName = _hostName;
-@synthesize address = _address;
-@synthesize reachabilityQueries = _reachabilityQueries;
-
-+ (Reachability *)sharedReachability
-{
- if (!_sharedReachability) {
- _sharedReachability = [[Reachability alloc] init];
- // Clients of Reachability will typically call [[Reachability sharedReachability] setHostName:]
- // before calling one of the status methods.
- _sharedReachability.hostName = nil;
- _sharedReachability.address = nil;
- _sharedReachability.networkStatusNotificationsEnabled = NO;
- _sharedReachability.reachabilityQueries = [[NSMutableDictionary alloc] init];
- }
- return _sharedReachability;
-}
-
-- (void) dealloc
-{
- [self stopListeningForReachabilityChanges];
-
- [_sharedReachability.reachabilityQueries release];
- [_sharedReachability release];
- [super dealloc];
-}
-
-- (BOOL)isReachableWithoutRequiringConnection:(SCNetworkReachabilityFlags)flags
-{
- // kSCNetworkReachabilityFlagsReachable indicates that the specified nodename or address can
- // be reached using the current network configuration.
- BOOL isReachable = flags & kSCNetworkReachabilityFlagsReachable;
-
- // This flag indicates that the specified nodename or address can
- // be reached using the current network configuration, but a
- // connection must first be established.
- //
- // If the flag is false, we don't have a connection. But because CFNetwork
- // automatically attempts to bring up a WWAN connection, if the WWAN reachability
- // flag is present, a connection is not required.
- BOOL noConnectionRequired = !(flags & kSCNetworkReachabilityFlagsConnectionRequired);
- if ((flags & kSCNetworkReachabilityFlagsIsWWAN)) {
- noConnectionRequired = YES;
- }
-
- return (isReachable && noConnectionRequired) ? YES : NO;
-}
-
-// Returns whether or not the current host name is reachable with the current network configuration.
-- (BOOL)isHostReachable:(NSString *)host
-{
- if (!host || ![host length]) {
- return NO;
- }
-
- SCNetworkReachabilityFlags flags;
- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [host UTF8String]);
- BOOL gotFlags = SCNetworkReachabilityGetFlags(reachability, &flags);
-
- CFRelease(reachability);
-
- if (!gotFlags) {
- return NO;
- }
-
- return [self isReachableWithoutRequiringConnection:flags];
-}
-
-// This returns YES if the address 169.254.0.0 is reachable without requiring a connection.
-- (BOOL)isAdHocWiFiNetworkAvailableFlags:(SCNetworkReachabilityFlags *)outFlags
-{
- // Look in the cache of reachability queries for one that matches this query.
- ReachabilityQuery *query = [self.reachabilityQueries objectForKey:kLinkLocalAddressKey];
- SCNetworkReachabilityRef adHocWiFiNetworkReachability = query.reachabilityRef;
-
- // If a cached reachability query was not found, create one.
- if (!adHocWiFiNetworkReachability) {
-
- // Build a sockaddr_in that we can pass to the address reachability query.
- struct sockaddr_in sin;
-
- bzero(&sin, sizeof(sin));
- sin.sin_len = sizeof(sin);
- sin.sin_family = AF_INET;
- // IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
- sin.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
-
- adHocWiFiNetworkReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&sin);
-
- query = [[[ReachabilityQuery alloc] init] autorelease];
- query.hostNameOrAddress = kLinkLocalAddressKey;
- query.reachabilityRef = adHocWiFiNetworkReachability;
-
- // Add the reachability query to the cache.
- [self.reachabilityQueries setObject:query forKey:kLinkLocalAddressKey];
- }
-
- // If necessary, register for notifcations for the SCNetworkReachabilityRef on the current run loop.
- // If an existing SCNetworkReachabilityRef was found in the cache, we can reuse it and register
- // to receive notifications from it in the current run loop, which may be different than the run loop
- // that was previously used when registering the SCNetworkReachabilityRef for notifications.
- // -scheduleOnRunLoop: will schedule only if network status notifications are enabled in the Reachability instance.
- // By default, they are not enabled.
- [query scheduleOnRunLoop:[NSRunLoop currentRunLoop]];
-
- SCNetworkReachabilityFlags addressReachabilityFlags;
- BOOL gotFlags = SCNetworkReachabilityGetFlags(adHocWiFiNetworkReachability, &addressReachabilityFlags);
- if (!gotFlags) {
- // There was an error getting the reachability flags.
- return NO;
- }
-
- // Callers of this method might want to use the reachability flags, so if an 'out' parameter
- // was passed in, assign the reachability flags to it.
- if (outFlags) {
- *outFlags = addressReachabilityFlags;
- }
-
- return [self isReachableWithoutRequiringConnection:addressReachabilityFlags];
-}
-
-// ReachabilityCallback is registered as the callback for network state changes in startListeningForReachabilityChanges.
-static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- // Post a notification to notify the client that the network reachability changed.
- [[NSNotificationCenter defaultCenter] postNotificationName:@"kNetworkReachabilityChangedNotification" object:nil];
-
- [pool release];
-}
-
-// Perform a reachability query for the address 0.0.0.0. If that address is reachable without
-// requiring a connection, a network interface is available. We'll have to do more work to
-// determine which network interface is available.
-- (BOOL)isNetworkAvailableFlags:(SCNetworkReachabilityFlags *)outFlags
-{
- ReachabilityQuery *query = [self.reachabilityQueries objectForKey:kDefaultRouteKey];
- SCNetworkReachabilityRef defaultRouteReachability = query.reachabilityRef;
-
- // If a cached reachability query was not found, create one.
- if (!defaultRouteReachability) {
-
- struct sockaddr_in zeroAddress;
- bzero(&zeroAddress, sizeof(zeroAddress));
- zeroAddress.sin_len = sizeof(zeroAddress);
- zeroAddress.sin_family = AF_INET;
-
- defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&zeroAddress);
-
- ReachabilityQuery *query = [[[ReachabilityQuery alloc] init] autorelease];
- query.hostNameOrAddress = kDefaultRouteKey;
- query.reachabilityRef = defaultRouteReachability;
-
- [self.reachabilityQueries setObject:query forKey:kDefaultRouteKey];
- }
-
- // If necessary, register for notifcations for the SCNetworkReachabilityRef on the current run loop.
- // If an existing SCNetworkReachabilityRef was found in the cache, we can reuse it and register
- // to receive notifications from it in the current run loop, which may be different than the run loop
- // that was previously used when registering the SCNetworkReachabilityRef for notifications.
- // -scheduleOnRunLoop: will schedule only if network status notifications are enabled in the Reachability instance.
- // By default, they are not enabled.
- [query scheduleOnRunLoop:[NSRunLoop currentRunLoop]];
-
- SCNetworkReachabilityFlags flags;
- BOOL gotFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags);
- if (!gotFlags) {
- return NO;
- }
-
- BOOL isReachable = [self isReachableWithoutRequiringConnection:flags];
-
- // Callers of this method might want to use the reachability flags, so if an 'out' parameter
- // was passed in, assign the reachability flags to it.
- if (outFlags) {
- *outFlags = flags;
- }
-
- return isReachable;
-}
-
-// Be a good citizen and unregister for network state changes when the application terminates.
-- (void)stopListeningForReachabilityChanges
-{
- // Walk through the cache that holds SCNetworkReachabilityRefs for reachability
- // queries to particular hosts or addresses.
- NSEnumerator *enumerator = [self.reachabilityQueries objectEnumerator];
- ReachabilityQuery *reachabilityQuery;
-
- while (reachabilityQuery = [enumerator nextObject]) {
-
- CFArrayRef runLoops = reachabilityQuery.runLoops;
- NSUInteger runLoopCounter, maxRunLoops = CFArrayGetCount(runLoops);
-
- for (runLoopCounter = 0; runLoopCounter < maxRunLoops; runLoopCounter++) {
- CFRunLoopRef nextRunLoop = (CFRunLoopRef)CFArrayGetValueAtIndex(runLoops, runLoopCounter);
-
- SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityQuery.reachabilityRef, nextRunLoop, kCFRunLoopDefaultMode);
- }
-
- CFArrayRemoveAllValues(reachabilityQuery.runLoops);
- }
-}
-
-/*
- Create a SCNetworkReachabilityRef for hostName, which lets us determine if hostName
- is currently reachable, and lets us register to receive notifications when the
- reachability of hostName changes.
- */
-- (SCNetworkReachabilityRef)reachabilityRefForHostName:(NSString *)hostName
-{
- if (!hostName || ![hostName length]) {
- return NULL;
- }
-
- // Look in the cache for an existing SCNetworkReachabilityRef for hostName.
- ReachabilityQuery *cachedQuery = [self.reachabilityQueries objectForKey:hostName];
- SCNetworkReachabilityRef reachabilityRefForHostName = cachedQuery.reachabilityRef;
-
- if (reachabilityRefForHostName) {
- return reachabilityRefForHostName;
- }
-
- // Didn't find an existing SCNetworkReachabilityRef for hostName, so create one ...
- reachabilityRefForHostName = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [hostName UTF8String]);
-
- NSAssert1(reachabilityRefForHostName != NULL, @"Failed to create SCNetworkReachabilityRef for host: %@", hostName);
-
- ReachabilityQuery *query = [[[ReachabilityQuery alloc] init] autorelease];
- query.hostNameOrAddress = hostName;
- query.reachabilityRef = reachabilityRefForHostName;
-
- // If necessary, register for notifcations for the SCNetworkReachabilityRef on the current run loop.
- // If an existing SCNetworkReachabilityRef was found in the cache, we can reuse it and register
- // to receive notifications from it in the current run loop, which may be different than the run loop
- // that was previously used when registering the SCNetworkReachabilityRef for notifications.
- // -scheduleOnRunLoop: will schedule only if network status notifications are enabled in the Reachability instance.
- // By default, they are not enabled.
- [query scheduleOnRunLoop:[NSRunLoop currentRunLoop]];
-
- // ... and add it to the cache.
- [self.reachabilityQueries setObject:query forKey:hostName];
- return reachabilityRefForHostName;
-}
-
-/*
- Create a SCNetworkReachabilityRef for the IP address in addressString, which lets us determine if
- the address is currently reachable, and lets us register to receive notifications when the
- reachability of the address changes.
- */
-- (SCNetworkReachabilityRef)reachabilityRefForAddress:(NSString *)addressString
-{
- if (!addressString || ![addressString length]) {
- return NULL;
- }
-
- struct sockaddr_in address;
-
- BOOL gotAddress = [self addressFromString:addressString address:&address];
- if (!gotAddress) {
- // The attempt to convert addressString to a sockaddr_in failed.
- NSAssert1(gotAddress != NO, @"Failed to convert an IP address string to a sockaddr_in: %@", addressString);
- return NULL;
- }
-
- // Look in the cache for an existing SCNetworkReachabilityRef for addressString.
- ReachabilityQuery *cachedQuery = [self.reachabilityQueries objectForKey:addressString];
- SCNetworkReachabilityRef reachabilityRefForAddress = cachedQuery.reachabilityRef;
-
- if (reachabilityRefForAddress) {
- return reachabilityRefForAddress;
- }
-
- // Didn't find an existing SCNetworkReachabilityRef for addressString, so create one.
- reachabilityRefForAddress = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (struct sockaddr *)&address);
-
- NSAssert1(reachabilityRefForAddress != NULL, @"Failed to create SCNetworkReachabilityRef for address: %@", addressString);
-
- ReachabilityQuery *query = [[[ReachabilityQuery alloc] init] autorelease];
- query.hostNameOrAddress = addressString;
- query.reachabilityRef = reachabilityRefForAddress;
-
- // If necessary, register for notifcations for the SCNetworkReachabilityRef on the current run loop.
- // If an existing SCNetworkReachabilityRef was found in the cache, we can reuse it and register
- // to receive notifications from it in the current run loop, which may be different than the run loop
- // that was previously used when registering the SCNetworkReachabilityRef for notifications.
- // -scheduleOnRunLoop: will schedule only if network status notifications are enabled in the Reachability instance.
- // By default, they are not enabled.
- [query scheduleOnRunLoop:[NSRunLoop currentRunLoop]];
-
- // ... and add it to the cache.
- [self.reachabilityQueries setObject:query forKey:addressString];
- return reachabilityRefForAddress;
-}
-
-- (NetworkStatus)remoteHostStatus
-{
- /*
- If the current host name or address is reachable, determine which network interface it is reachable through.
- If the host is reachable and the reachability flags include kSCNetworkReachabilityFlagsIsWWAN, it
- is reachable through the carrier data network. If the host is reachable and the reachability
- flags do not include kSCNetworkReachabilityFlagsIsWWAN, it is reachable through the WiFi network.
- */
-
- SCNetworkReachabilityRef reachabilityRef = nil;
- if (self.hostName) {
- reachabilityRef = [self reachabilityRefForHostName:self.hostName];
-
- } else if (self.address) {
- reachabilityRef = [self reachabilityRefForAddress:self.address];
-
- } else {
- NSAssert(self.hostName != nil && self.address != nil, @"No hostName or address specified. Cannot determine reachability.");
- return NotReachable;
- }
-
- if (!reachabilityRef) {
- return NotReachable;
- }
-
- SCNetworkReachabilityFlags reachabilityFlags;
- BOOL gotFlags = SCNetworkReachabilityGetFlags(reachabilityRef, &reachabilityFlags);
- if (!gotFlags) {
- return NotReachable;
- }
-
- BOOL reachable = [self isReachableWithoutRequiringConnection:reachabilityFlags];
-
- if (!reachable) {
- return NotReachable;
- }
- if (reachabilityFlags & ReachableViaCarrierDataNetwork) {
- return ReachableViaCarrierDataNetwork;
- }
-
- return ReachableViaWiFiNetwork;
-}
-
-- (NetworkStatus)internetConnectionStatus
-{
- /*
- To determine if the device has an Internet connection, query the address
- 0.0.0.0. If it's reachable without requiring a connection, first check
- for the kSCNetworkReachabilityFlagsIsDirect flag, which tell us if the connection
- is to an ad-hoc WiFi network. If it is not, the device can access the Internet.
- The next thing to determine is how the device can access the Internet, which
- can either be through the carrier data network (EDGE or other service) or through
- a WiFi connection.
-
- Note: Knowing that the device has an Internet connection is not the same as
- knowing if the device can reach a particular host. To know that, use
- -[Reachability remoteHostStatus].
- */
-
- SCNetworkReachabilityFlags defaultRouteFlags;
- BOOL defaultRouteIsAvailable = [self isNetworkAvailableFlags:&defaultRouteFlags];
- if (defaultRouteIsAvailable) {
-
- if (defaultRouteFlags & kSCNetworkReachabilityFlagsIsDirect) {
-
- // The connection is to an ad-hoc WiFi network, so Internet access is not available.
- return NotReachable;
- }
- else if (defaultRouteFlags & ReachableViaCarrierDataNetwork) {
- return ReachableViaCarrierDataNetwork;
- }
-
- return ReachableViaWiFiNetwork;
- }
-
- return NotReachable;
-}
-
-- (NetworkStatus)localWiFiConnectionStatus
-{
- SCNetworkReachabilityFlags selfAssignedAddressFlags;
-
- /*
- To determine if the WiFi connection is to a local ad-hoc network,
- check the availability of the address 169.254.x.x. That's an address
- in the self-assigned range, and the device will have a self-assigned IP
- when it's connected to a ad-hoc WiFi network. So to test if the device
- has a self-assigned IP, look for the kSCNetworkReachabilityFlagsIsDirect flag
- in the address query. If it's present, we know that the WiFi connection
- is to an ad-hoc network.
- */
- // This returns YES if the address 169.254.0.0 is reachable without requiring a connection.
- BOOL hasLinkLocalNetworkAccess = [self isAdHocWiFiNetworkAvailableFlags:&selfAssignedAddressFlags];
-
- if (hasLinkLocalNetworkAccess && (selfAssignedAddressFlags & kSCNetworkReachabilityFlagsIsDirect)) {
- return ReachableViaWiFiNetwork;
- }
-
- return NotReachable;
-}
-
-// Convert an IP address from an NSString to a sockaddr_in * that can be used to create
-// the reachability request.
-- (BOOL)addressFromString:(NSString *)IPAddress address:(struct sockaddr_in *)address
-{
- if (!IPAddress || ![IPAddress length]) {
- return NO;
- }
-
- memset((char *) address, sizeof(struct sockaddr_in), 0);
- address->sin_family = AF_INET;
- address->sin_len = sizeof(struct sockaddr_in);
-
- int conversionResult = inet_aton([IPAddress UTF8String], &address->sin_addr);
- if (conversionResult == 0) {
- NSAssert1(conversionResult != 1, @"Failed to convert the IP address string into a sockaddr_in: %@", IPAddress);
- return NO;
- }
-
- return YES;
-}
-
-@end
-
-@interface ReachabilityQuery ()
-- (CFRunLoopRef)startListeningForReachabilityChanges:(SCNetworkReachabilityRef)reachability onRunLoop:(CFRunLoopRef)runLoop;
-@end
-
-@implementation ReachabilityQuery
-
-@synthesize reachabilityRef = _reachabilityRef;
-@synthesize runLoops = _runLoops;
-@synthesize hostNameOrAddress = _hostNameOrAddress;
-
-- (id)init
-{
- self = [super init];
- if (self != nil) {
- self.runLoops = CFArrayCreateMutable(kCFAllocatorDefault, 0, NULL);
- }
- return self;
-}
-
-- (void)dealloc
-{
- CFRelease(self.runLoops);
- [super dealloc];
-}
-
-- (BOOL)isScheduledOnRunLoop:(CFRunLoopRef)runLoop
-{
- NSUInteger runLoopCounter, maxRunLoops = CFArrayGetCount(self.runLoops);
-
- for (runLoopCounter = 0; runLoopCounter < maxRunLoops; runLoopCounter++) {
- CFRunLoopRef nextRunLoop = (CFRunLoopRef)CFArrayGetValueAtIndex(self.runLoops, runLoopCounter);
-
- if (nextRunLoop == runLoop) {
- return YES;
- }
- }
-
- return NO;
-}
-
-- (void)scheduleOnRunLoop:(NSRunLoop *)inRunLoop
-{
- // Only register for network state changes if the client has specifically enabled them.
- if ([[Reachability sharedReachability] networkStatusNotificationsEnabled] == NO) {
- return;
- }
-
- if (!inRunLoop) {
- return;
- }
-
- CFRunLoopRef runLoop = [inRunLoop getCFRunLoop];
-
- // Notifications of status changes for each reachability query can be scheduled on multiple run loops.
- // To support that, register for notifications for each runLoop.
- // -isScheduledOnRunLoop: iterates over all of the run loops that have previously been used
- // to register for notifications. If one is found that matches the passed in runLoop argument, there's
- // no need to register for notifications again. If one is not found, register for notifications
- // using the current runLoop.
- if (![self isScheduledOnRunLoop:runLoop]) {
-
- CFRunLoopRef notificationRunLoop = [self startListeningForReachabilityChanges:self.reachabilityRef onRunLoop:runLoop];
- if (notificationRunLoop) {
- CFArrayAppendValue(self.runLoops, notificationRunLoop);
- }
- }
-}
-
-// Register to receive changes to the 'reachability' query so that we can update the
-// user interface when the network state changes.
-- (CFRunLoopRef)startListeningForReachabilityChanges:(SCNetworkReachabilityRef)reachability onRunLoop:(CFRunLoopRef)runLoop
-{
- if (!reachability) {
- return NULL;
- }
-
- if (!runLoop) {
- return NULL;
- }
-
- SCNetworkReachabilityContext context = {0, self, NULL, NULL, NULL};
- SCNetworkReachabilitySetCallback(reachability, ReachabilityCallback, &context);
- SCNetworkReachabilityScheduleWithRunLoop(reachability, runLoop, kCFRunLoopDefaultMode);
-
- return runLoop;
-}
-
-
-@end
diff --git a/iphone/FixMyStreet/Classes/Report.h b/iphone/FixMyStreet/Classes/Report.h
deleted file mode 100644
index 2e7b153cb..000000000
--- a/iphone/FixMyStreet/Classes/Report.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//
-// Report.h
-// FixMyStreet
-//
-// Created by Matthew on 29/09/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-#import <CoreLocation/CoreLocation.h>
-
-@interface Report : NSObject {
-}
-@end
diff --git a/iphone/FixMyStreet/Classes/Report.m b/iphone/FixMyStreet/Classes/Report.m
deleted file mode 100644
index afd71ede4..000000000
--- a/iphone/FixMyStreet/Classes/Report.m
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-// Report.m
-// FixMyStreet
-//
-// Created by Matthew on 29/09/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-/*
-#import "Report.h"
-
-static Report *sharedReport = nil;
-
-@implementation Report
-
-@synthesize image, location, subject;
-
--(void)uploadReport {
-}
-
-// See "Creating a Singleton Instance" in the Cocoa Fundamentals Guide for more info
-
-+ (Report *)sharedInstance {
- @synchronized(self) {
- if (sharedReport == nil) {
- [[self alloc] init]; // assignment not done here
- }
- }
- return sharedReport;
-}
-
-+ (id)allocWithZone:(NSZone *)zone {
- @synchronized(self) {
- if (sharedReport == nil) {
- sharedReport = [super allocWithZone:zone];
- return sharedReport; // assignment and return on first allocation
- }
- }
- return nil; // on subsequent allocation attempts return nil
-}
-
-- (id)copyWithZone:(NSZone *)zone
-{
- return self;
-}
-
-- (id)retain {
- return self;
-}
-
-- (unsigned)retainCount {
- return UINT_MAX; // denotes an object that cannot be released
-}
-
-- (void)release {
- //do nothing
-}
-
-- (id)autorelease {
- return self;
-}
-
-@end
-*/
diff --git a/iphone/FixMyStreet/Classes/SettingsViewController.h b/iphone/FixMyStreet/Classes/SettingsViewController.h
deleted file mode 100644
index 1030129f9..000000000
--- a/iphone/FixMyStreet/Classes/SettingsViewController.h
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// SettingsViewController.h
-// FixMyStreet
-//
-// Created by Matthew on 20/10/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-@interface SettingsViewController : UITableViewController {
- UILabel *nameLabel;
- UILabel *nameCurrent;
- UILabel *emailLabel;
- UILabel *emailCurrent;
- UILabel *phoneLabel;
- UILabel *phoneCurrent;
-
- BOOL firstTime;
-}
-
-@property (nonatomic, assign) BOOL firstTime;
-
-@end
diff --git a/iphone/FixMyStreet/Classes/SettingsViewController.m b/iphone/FixMyStreet/Classes/SettingsViewController.m
deleted file mode 100644
index c352f362a..000000000
--- a/iphone/FixMyStreet/Classes/SettingsViewController.m
+++ /dev/null
@@ -1,214 +0,0 @@
-//
-// SettingsViewController.m
-// FixMyStreet
-//
-// Created by Matthew on 20/10/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import "SettingsViewController.h"
-#import "FixMyStreetAppDelegate.h"
-#import "EditSubjectViewController.h"
-
-@implementation SettingsViewController
-
-@synthesize firstTime;
-
-/*
-- (id)initWithStyle:(UITableViewStyle)style {
- // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- if (self = [super initWithStyle:style]) {
- }
- return self;
-}
-*/
-
-// Implement viewDidLoad to do additional setup after loading the view.
-- (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"Your details";
- self.tableView.sectionHeaderHeight = 20.0;
- self.tableView.sectionFooterHeight = 0.0;
- self.tableView.scrollEnabled = NO;
-
- UIBarButtonItem* backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonSystemItemCancel target:nil action:nil];
- self.navigationItem.backBarButtonItem = backBarButtonItem;
- [backBarButtonItem release];
-
-}
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- if (self.firstTime)
- return 4;
- return 3;
-}
-
-- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
- return nil;
-}
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 1;
-}
-
-- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.section == 3) {
- return 54.0;
- }
- return 44.0;
-}
-
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- if (indexPath.section == 3) {
- static NSString *CellIdentifier = @"InfoCell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
- UITextView *blurb = [[UITextView alloc] initWithFrame:CGRectMake(10, 0, 280, 44)];
- blurb.font = [UIFont italicSystemFontOfSize:14];
- blurb.textAlignment = UITextAlignmentCenter;
- blurb.editable = NO;
- blurb.text = @"Please fill in your details, and\nwe'll remember them for next time";
- [cell.contentView addSubview:blurb];
- [blurb release];
- }
- return cell;
- }
-
- static NSString *CellIdentifier = @"Cell";
- FixMyStreetAppDelegate* delegate = [[UIApplication sharedApplication] delegate];
-
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- }
-
- NSString *text, *placeholder;
- UILabel *label, *current;
- if (indexPath.section == 0) {
- text = delegate.name;
- if (!nameLabel) {
- nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10,0,70,40)];
- nameLabel.font = [UIFont boldSystemFontOfSize:17];
- nameLabel.text = @"Name:";
- [cell.contentView addSubview:nameLabel];
- }
- label = nameLabel;
- if (!nameCurrent) {
- nameCurrent = [[UILabel alloc] initWithFrame:CGRectMake(80,0,190,40)];
- nameCurrent.font = [UIFont systemFontOfSize:17];
- [cell.contentView addSubview:nameCurrent];
- }
- current = nameCurrent;
- placeholder = @"Your name";
- } else if (indexPath.section == 1) {
- text = delegate.email;
- if (!emailLabel) {
- emailLabel = [[UILabel alloc] initWithFrame:CGRectMake(10,0,70,40)];
- emailLabel.font = [UIFont boldSystemFontOfSize:17];
- emailLabel.text = @"Email:";
- [cell.contentView addSubview:emailLabel];
- }
- label = emailLabel;
- if (!emailCurrent) {
- emailCurrent = [[UILabel alloc] initWithFrame:CGRectMake(80,0,190,40)];
- emailCurrent.font = [UIFont systemFontOfSize:17];
- [cell.contentView addSubview:emailCurrent];
- }
- current = emailCurrent;
- placeholder = @"Your email";
- } else if (indexPath.section == 2) {
- text = delegate.phone;
- if (!phoneLabel) {
- phoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(10,0,70,40)];
- phoneLabel.font = [UIFont boldSystemFontOfSize:17];
- phoneLabel.text = @"Phone:";
- [cell.contentView addSubview:phoneLabel];
- }
- label = phoneLabel;
- if (!phoneCurrent) {
- phoneCurrent = [[UILabel alloc] initWithFrame:CGRectMake(80,0,190,40)];
- phoneCurrent.font = [UIFont systemFontOfSize:17];
- [cell.contentView addSubview:phoneCurrent];
- }
- current = phoneCurrent;
- placeholder = @"Your phone (optional)";
- }
-
- if (text) {
- label.hidden = NO;
- cell.textLabel.text = nil;
- current.text = text;
- current.hidden = NO;
- // cell.accessoryType = UITableViewCellAccessoryCheckmark;
- } else {
- label.hidden = YES;
- current.hidden = YES;
- cell.textLabel.text = placeholder;
- cell.textLabel.textColor = [UIColor grayColor];
- // cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- }
-
- return cell;
-}
-
-
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- if (indexPath.section == 3) {
- return;
- }
-
- FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
- EditSubjectViewController* editSubjectViewController = [[EditSubjectViewController alloc] initWithStyle:UITableViewStyleGrouped];
- if (indexPath.section == 0) {
- [editSubjectViewController setAll:delegate.name viewTitle:@"Edit name" placeholder:@"Your name" keyboardType:UIKeyboardTypeDefault capitalisation:UITextAutocapitalizationTypeWords];
- } else if (indexPath.section == 1) {
- [editSubjectViewController setAll:delegate.email viewTitle:@"Edit email" placeholder:@"Your email" keyboardType:UIKeyboardTypeEmailAddress capitalisation:UITextAutocapitalizationTypeNone];
- } else if (indexPath.section == 2) {
- [editSubjectViewController setAll:delegate.phone viewTitle:@"Edit phone" placeholder:@"Your phone number" keyboardType:UIKeyboardTypeNumbersAndPunctuation capitalisation:UITextAutocapitalizationTypeNone];
- }
-
- [self.navigationController pushViewController:editSubjectViewController animated:YES];
- [editSubjectViewController release];
-}
-
-- (void)viewWillAppear:(BOOL)animated {
- [self.tableView reloadData];
-// [super viewWillAppear:animated];
-}
-
-/*
-- (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
-}
-*/
-/*
-- (void)viewWillDisappear:(BOOL)animated {
-}
-*/
-/*
-- (void)viewDidDisappear:(BOOL)animated {
-}
-*/
-/*
-- (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
-}
-*/
-
-- (void)dealloc {
- [nameLabel release];
- [emailLabel release];
- [phoneLabel release];
- [nameCurrent release];
- [emailCurrent release];
- [phoneCurrent release];
- [super dealloc];
-}
-
-
-@end
-
diff --git a/iphone/FixMyStreet/Classes/imageCell.h b/iphone/FixMyStreet/Classes/imageCell.h
deleted file mode 100644
index 585ca7da1..000000000
--- a/iphone/FixMyStreet/Classes/imageCell.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//
-// imageCell.h
-// FixMyStreet
-//
-// Created by Matthew on 29/09/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-@interface imageCell : UITableViewCell {
- UILabel* labelView;
- UIImageView* imageView;
-}
-
-@property (nonatomic, retain) UIImageView* imageView;
-@property (nonatomic, retain) UILabel* labelView;
-
--(void)setData:(UIImage *)newImage;
-
-@end
diff --git a/iphone/FixMyStreet/Classes/imageCell.m b/iphone/FixMyStreet/Classes/imageCell.m
deleted file mode 100644
index 9b295bdfb..000000000
--- a/iphone/FixMyStreet/Classes/imageCell.m
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-// imageCell.m
-// FixMyStreet
-//
-// Created by Matthew on 29/09/2008.
-// Copyright 2008 UK Citizens Online Democracy. All rights reserved.
-//
-
-#import "imageCell.h"
-
-
-@implementation imageCell
-
-@synthesize imageView;
-@synthesize labelView;
-
-- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
-
- UIFont *font = [UIFont boldSystemFontOfSize:17.0];
- UILabel *newLabel = [[UILabel alloc] initWithFrame:CGRectZero];
- newLabel.backgroundColor = [UIColor clearColor];
- //newLabel.backgroundColor = [UIColor whiteColor];
- newLabel.opaque = YES;
- newLabel.textColor = [UIColor blackColor];
- newLabel.text = @"Take photo";
- newLabel.highlightedTextColor = [UIColor whiteColor];
- newLabel.font = font;
- newLabel.textAlignment = UITextAlignmentLeft; // default
- self.labelView = newLabel;
- [self.contentView addSubview:newLabel];
- [newLabel release];
- self.imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
- [self.contentView addSubview:self.imageView];
- //[self.imageView release];
-
- }
- return self;
-}
-
--(void)setData:(UIImage *)newImage {
- //CGSize imageSize = newImage.size;
- //float w = 100.0 / imageSize.width;
- //imageView.frame = CGRectMake(150,5,100,imageSize.height * w);
- //CGRect contentRect = self.contentView.bounds;
- //contentRect.size = CGSizeMake(contentRect.size.width, imageSize.height*w);
- imageView.image = newImage;
- //self.contentView.bounds = contentRect;
-}
-
--(void)layoutSubviews {
- [super layoutSubviews];
- if (imageView.image) {
- CGSize imageSize = imageView.image.size;
- float w = 100.0 / imageSize.width;
- imageView.frame = CGRectMake(10,0,100,imageSize.height * w);
- labelView.frame = CGRectMake(120, imageSize.height * w / 2, 200, 20);
- CGRect contentRect = self.contentView.bounds;
- contentRect.size = CGSizeMake(contentRect.size.width, imageSize.height*w);
- self.contentView.bounds = contentRect;
- } else {
- labelView.frame = CGRectMake(10, 0, 200, 44);
- }
-}
-
-- (void)dealloc {
- [imageView dealloc];
- [labelView dealloc];
- [super dealloc];
-}
-
-@end
diff --git a/iphone/FixMyStreet/Classes/mysociety.png b/iphone/FixMyStreet/Classes/mysociety.png
deleted file mode 100644
index 8a9280c16..000000000
--- a/iphone/FixMyStreet/Classes/mysociety.png
+++ /dev/null
Binary files differ