Skip to content

Commit

Permalink
added wifi bssid location lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
nst committed Oct 31, 2010
1 parent 111247a commit 880ba9a
Show file tree
Hide file tree
Showing 52 changed files with 5,685 additions and 598 deletions.
9 changes: 8 additions & 1 deletion Classes/SPSourceKeyboardTVC.m
Expand Up @@ -63,7 +63,14 @@ - (void)loadData {
NSMutableSet *set = [NSMutableSet set];

NSString *dir = @"/var/mobile/Library/Keyboard/";
NSArray *dirContents = [[NSFileManager defaultManager] directoryContentsAtPath:dir];
NSError *error = nil;
NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:dir error:&error];

if(dirContents == nil) {
NSLog(@"-- error: %@", error);
return;
}

for(NSString *filePath in dirContents) {
if(![filePath hasSuffix:@".dat"]) continue;
NSArray *a = [self wordsInDictionaryCacheFileAtPath:[dir stringByAppendingPathComponent:filePath]];
Expand Down
6 changes: 5 additions & 1 deletion Classes/SPSourceLocationTVC.h
Expand Up @@ -11,6 +11,8 @@
#import <MapKit/MapKit.h>
#import "SPSourceTVC.h"

@class CLLocation;

@interface SPSourceLocationTVC : SPSourceTVC /* <MKReverseGeocoderDelegate> */ {
NSArray *items;
// MKReverseGeocoder *geo;
Expand All @@ -20,11 +22,13 @@
NSString *locDateString;
NSString *timezone;
NSArray *cities;

CLLocation *cachedLocationFromMaps;
}

//@property (nonatomic, retain) MKReverseGeocoder *geo;
@property (nonatomic, retain) NSString *geoString;

@property (nonatomic, retain) CLLocation *cachedLocationFromMaps;
@property (nonatomic, retain) NSArray *cities;
@property (nonatomic, retain) NSString *locString;
@property (nonatomic, retain) NSString *locDateString;
Expand Down
14 changes: 14 additions & 0 deletions Classes/SPSourceLocationTVC.m
Expand Up @@ -9,6 +9,8 @@

#import "SPSourceLocationTVC.h"
#import <CoreLocation/CoreLocation.h>
#import "SPMapVC.h"
#import "SPImageAnnotation.h"

@implementation SPSourceLocationTVC

Expand All @@ -18,6 +20,16 @@ @implementation SPSourceLocationTVC
@synthesize locString;
@synthesize locDateString;
@synthesize timezone;
@synthesize cachedLocationFromMaps;

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.section == 0 && indexPath.row == 0 && cachedLocationFromMaps) {
SPMapVC *mapVC = [[SPMapVC alloc] initWithNibName:@"SPMapVC" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:mapVC animated:YES];
SPImageAnnotation *annotation = [SPImageAnnotation annotationWithCoordinate:cachedLocationFromMaps.coordinate date:nil path:nil];
[mapVC addAnnotation:annotation];
}
}

- (void)loadData {
if(contentsDictionaries) return;
Expand All @@ -26,6 +38,7 @@ - (void)loadData {
NSDictionary *d = [NSDictionary dictionaryWithContentsOfFile:path];
NSData *data = [d valueForKey:@"UserLocation"];
CLLocation *loc = data ? [NSKeyedUnarchiver unarchiveObjectWithData:data] : nil;
self.cachedLocationFromMaps = loc;
self.locString = @"";
self.locDateString = @"";
if(loc) {
Expand Down Expand Up @@ -62,6 +75,7 @@ - (void)dealloc {
[items release];
// [geo release];
[geoString release];
[cachedLocationFromMaps release];
[super dealloc];
}
/*
Expand Down
3 changes: 2 additions & 1 deletion Classes/SPSourceWifiTVC.h
Expand Up @@ -9,8 +9,9 @@

#import <UIKit/UIKit.h>
#import "SPSourceTVC.h"
#import "OUILookupTool.h"

@interface SPSourceWifiTVC : SPSourceTVC {
@interface SPSourceWifiTVC : SPSourceTVC <OUILookupToolDelegate> {

}

Expand Down
12 changes: 12 additions & 0 deletions Classes/SPSourceWifiTVC.m
Expand Up @@ -8,10 +8,14 @@
//

#import "SPSourceWifiTVC.h"
#import "OUILookupTool.h"

@implementation SPSourceWifiTVC

- (void)loadData {

//[OUILookupTool lookupBSSID:@"0:30:bd:97:7:72" delegate:self];

if(contentsDictionaries) return;

self.contentsDictionaries = [NSMutableArray array];
Expand All @@ -24,6 +28,8 @@ - (void)loadData {
if(!a) return;

for(NSDictionary *d in a) {
[OUILookupTool locateWifiAccessPoint:d delegate:self];

NSString *name = [d valueForKey:@"SSID_STR"];

NSData *joined = [d valueForKey:@"lastJoined"];
Expand All @@ -35,4 +41,10 @@ - (void)loadData {
}
}

#pragma mark OUILookupTool

- (void)OUILookupTool:(OUILookupTool *)ouiLookupTool didLocateAccessPoint:(NSDictionary *)ap {
//NSLog(@"-- %@", ap);
}

@end
20 changes: 10 additions & 10 deletions Classes/SpyPhoneAppDelegate.m
Expand Up @@ -9,10 +9,11 @@

#import "SpyPhoneAppDelegate.h"

@interface UIApplication (tvout)
- (void) startTVOut;
@end

//
//@interface UIApplication (tvout)
//- (void) startTVOut;
//@end
//
@implementation SpyPhoneAppDelegate

@synthesize window;
Expand All @@ -23,12 +24,11 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application {

// Add the tab bar controller's current view as a subview of the window
[window addSubview:tabBarController.view];
/*
BOOL isTVOutEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"TVOutEnabled"];
if(isTVOutEnabled) {
[[UIApplication sharedApplication] startTVOut];
}
*/

// BOOL isTVOutEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"TVOutEnabled"];
// if(isTVOutEnabled) {
// [[TVOutManager sharedInstance] startTVOut];
// }
}


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
67 changes: 67 additions & 0 deletions JSON/JSON.h
@@ -0,0 +1,67 @@
/*
Copyright (C) 2009-2010 Stig Brautaset. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/**
@mainpage A strict JSON parser and generator for Objective-C
JSON (JavaScript Object Notation) is a lightweight data-interchange
format. This framework provides two apis for parsing and generating
JSON. One standard object-based and a higher level api consisting of
categories added to existing Objective-C classes.
This framework does its best to be as strict as possible, both in what it accepts and what it generates. For example, it does not support trailing commas in arrays or objects. Nor does it support embedded comments, or anything else not in the JSON specification. This is considered a feature.
@section Links
@li <a href="http://stig.github.com/json-framework">Project home page</a>.
@li Online version of the <a href="http://stig.github.com/json-framework/api">API documentation</a>.
*/


// This setting of 1 is best if you copy the source into your project.
// The build transforms the 1 to a 0 when building the framework and static lib.

#if 1

#import "SBJsonParser.h"
#import "SBJsonWriter.h"
#import "SBJsonStreamWriter.h"
#import "NSObject+SBJSON.h"
#import "NSString+SBJSON.h"

#else
#import <JSON/SBJsonParser.h>
#import <JSON/SBJsonWriter.h>
#import <JSON/SBJsonStreamWriter.h>
#import <JSON/NSObject+SBJSON.h>
#import <JSON/NSString+SBJSON.h>
#endif
24 changes: 24 additions & 0 deletions JSON/LICENSE
@@ -0,0 +1,24 @@
Copyright (C) 2007-2010 Stig Brautaset. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 changes: 53 additions & 0 deletions JSON/NSObject+SBJSON.h
@@ -0,0 +1,53 @@
/*
Copyright (C) 2009 Stig Brautaset. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#import <Foundation/Foundation.h>


/**
@brief Adds JSON generation to Foundation classes
This is a category on NSObject that adds methods for returning JSON representations
of standard objects to the objects themselves. This means you can call the
-JSONRepresentation method on an NSArray object and it'll do what you want.
*/
@interface NSObject (NSObject_SBJSON)

/**
@brief Returns a string containing the receiver encoded in JSON.
This method is added as a category on NSObject but is only actually
supported for the following objects:
@li NSDictionary
@li NSArray
*/
- (NSString *)JSONRepresentation;

@end

44 changes: 44 additions & 0 deletions JSON/NSObject+SBJSON.m
@@ -0,0 +1,44 @@
/*
Copyright (C) 2009 Stig Brautaset. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "NSObject+SBJSON.h"
#import "SBJsonWriter.h"

@implementation NSObject (NSObject_SBJSON)

- (NSString *)JSONRepresentation {
SBJsonWriter *jsonWriter = [SBJsonWriter new];
NSString *json = [jsonWriter stringWithObject:self];
if (!json)
NSLog(@"-JSONRepresentation failed. Error trace is: %@", [jsonWriter errorTrace]);
[jsonWriter release];
return json;
}

@end

0 comments on commit 880ba9a

Please sign in to comment.