-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Can be compiled directly in Xcode and deployed to iOS Device
- Loading branch information
0 parents
commit 0ed1cee
Showing
4,896 changed files
with
1,398,687 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Xcode user-specific files | ||
*xcuserdata* | ||
*.pbxuser | ||
*.perspectivev3 | ||
|
||
# compiled object files | ||
*.o | ||
|
||
# vim swap files | ||
.*.swp |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface AltAds : UIView <UIWebViewDelegate> | ||
{ | ||
UIWebView* AdView; | ||
BOOL loadAdInFrame; | ||
} | ||
- (id) initWithFrame:(CGRect)frame andWindow:(UIWindow*)_window; | ||
- (void) webViewDidFinishLoad:(UIWebView*) webView; | ||
- (void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error; | ||
- (void) RefreshAd; | ||
- (void) startMyOwnAds; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#import "AltAds.h" | ||
#include <sys/stat.h> | ||
|
||
#define MY_OWN_URL @"" | ||
|
||
@implementation AltAds | ||
|
||
//******************************************************************************************* | ||
// initWithFrame: This initializes the AltAds view. | ||
//******************************************************************************************* | ||
- (id) initWithFrame:(CGRect)frame andWindow:(UIWindow*)_window | ||
{ | ||
if (self = [super initWithFrame:frame]) | ||
{ | ||
UIView* SpacerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320.0f, 55.0f)]; | ||
SpacerView.backgroundColor = [UIColor clearColor]; | ||
[self addSubview:SpacerView]; | ||
[SpacerView release]; | ||
|
||
[self startMyOwnAds]; | ||
|
||
if(_window != nil) | ||
{ | ||
[_window addSubview:self]; | ||
} | ||
} | ||
|
||
return self; | ||
} | ||
|
||
//******************************************************************************************* | ||
// dealloc - class destructor. | ||
//******************************************************************************************* | ||
- (void) dealloc | ||
{ | ||
if(AdView != nil) | ||
[AdView release]; | ||
[super dealloc]; | ||
} | ||
|
||
//******************************************************************************************* | ||
// RefreshAd - Call this to get a new ad. | ||
//******************************************************************************************* | ||
- (void) RefreshAd | ||
{ | ||
if(AdView.loading == NO) | ||
{ | ||
NSURL* Url = [NSURL URLWithString:MY_OWN_URL]; | ||
loadAdInFrame = YES; | ||
[AdView loadRequest:[NSURLRequest requestWithURL:Url]]; | ||
} | ||
} | ||
|
||
//******************************************************************************************* | ||
// webViewDidFinishLoad - This is the UIWebView Delegate for when a page has finished loading. | ||
// Here we will add the view if its not added, we will reset the | ||
// refresh timer to fetch the next ad. | ||
//******************************************************************************************* | ||
- (void) webViewDidFinishLoad:(UIWebView*) webView | ||
{ | ||
static BOOL AddedAlready = NO; | ||
loadAdInFrame = NO; | ||
NSLog(@"AltAds received an ad\n"); | ||
if(AddedAlready == NO) | ||
{ | ||
AddedAlready = YES; | ||
[self addSubview:AdView]; | ||
} | ||
} | ||
|
||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event | ||
{ | ||
NSLog(@"Clicked\n"); | ||
} | ||
|
||
//******************************************************************************************* | ||
// didFailLoadWithError - Occurs when the page could not load. | ||
//******************************************************************************************* | ||
- (void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error | ||
{ | ||
NSLog(@"Fail to fetch ad\n"); | ||
} | ||
|
||
//******************************************************************************************* | ||
// shouldStartLoadWithRequest - When the webview is going to load a page, this function runs. | ||
// We'll use this to handle the "click". | ||
//******************************************************************************************* | ||
- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType | ||
{ | ||
BOOL ShouldLoad = NO; | ||
|
||
if(loadAdInFrame == YES) | ||
{ | ||
ShouldLoad = YES; | ||
} | ||
else | ||
{ | ||
[[UIApplication sharedApplication] openURL: [request URL]]; | ||
} | ||
|
||
return ShouldLoad; | ||
} | ||
|
||
//******************************************************************************************* | ||
// Starts my own ads. | ||
//******************************************************************************************* | ||
- (void) startMyOwnAds | ||
{ | ||
NSLog(@"Starting my own\n"); | ||
AdView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 55.0f)]; | ||
[AdView setDelegate:self]; | ||
[self RefreshAd]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (C) 2009 by Matthias Ringwald | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. 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. | ||
* 3. Neither the name of the copyright holders nor the names of | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD 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 MATTHIAS | ||
* RINGWALD 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. | ||
* | ||
*/ | ||
|
||
// | ||
// BTDevice.h | ||
// BT-Keyboard | ||
// | ||
// Created by Matthias Ringwald on 3/30/09. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#include <btstack/utils.h> | ||
|
||
#define kCODHID 0x2540 | ||
#define kCODZeeMote 0x584 | ||
#define kCODInvalid 0xffff | ||
|
||
typedef enum { | ||
kBluetoothDeviceTypeGeneric = 0, | ||
kBluetoothDeviceTypeHID, | ||
kBluetoothDeviceTypeMobilePhone, | ||
kBluetoothDeviceTypeSmartPhone, | ||
kBluetoothDeviceTypeZeeMote, | ||
} BluetoothDeviceType; | ||
|
||
typedef enum { | ||
kBluetoothConnectionNotConnected = 0, | ||
kBluetoothConnectionRemoteName, | ||
kBluetoothConnectionConnecting, | ||
kBluetoothConnectionConnected | ||
} BluetoothConnectionState; | ||
|
||
@interface BTDevice : NSObject { | ||
bd_addr_t address; | ||
NSString * name; | ||
uint8_t pageScanRepetitionMode; | ||
uint16_t clockOffset; | ||
uint32_t classOfDevice; | ||
BluetoothConnectionState connectionState; | ||
} | ||
|
||
- (void) setAddress:(bd_addr_t *)addr; | ||
- (bd_addr_t *) address; | ||
- (NSString *) toString; | ||
+ (NSString *) stringForAddress:(bd_addr_t *) address; | ||
|
||
@property (readonly) BluetoothDeviceType deviceType; | ||
@property (readonly) NSString * nameOrAddress; | ||
@property (nonatomic, copy) NSString * name; | ||
@property (nonatomic, assign) uint32_t classOfDevice; | ||
@property (nonatomic, assign) uint16_t clockOffset; | ||
@property (nonatomic, assign) uint8_t pageScanRepetitionMode; | ||
@property (nonatomic, assign) BluetoothConnectionState connectionState; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright (C) 2009 by Matthias Ringwald | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. 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. | ||
* 3. Neither the name of the copyright holders nor the names of | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD 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 MATTHIAS | ||
* RINGWALD 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. | ||
* | ||
*/ | ||
|
||
// | ||
// BTDevice.m | ||
// | ||
// Created by Matthias Ringwald on 3/30/09. | ||
// | ||
|
||
#import "BTDevice.h" | ||
|
||
@implementation BTDevice | ||
|
||
@synthesize name; | ||
@synthesize classOfDevice; | ||
@synthesize connectionState; | ||
@synthesize pageScanRepetitionMode; | ||
@synthesize clockOffset; | ||
|
||
- (BTDevice *)init { | ||
name = NULL; | ||
bzero(&address, 6); | ||
classOfDevice = kCODInvalid; | ||
connectionState = kBluetoothConnectionNotConnected; | ||
return self; | ||
} | ||
|
||
- (void) setAddress:(bd_addr_t *)newAddr{ | ||
BD_ADDR_COPY( &address, newAddr); | ||
} | ||
|
||
- (bd_addr_t *) address{ | ||
return &address; | ||
} | ||
|
||
+ (NSString *) stringForAddress:(bd_addr_t *) address { | ||
uint8_t * addr = (uint8_t*) address; | ||
return [NSString stringWithFormat:@"%02x:%02x:%02x:%02x:%02x:%02x", addr[0], addr[1], addr[2], | ||
addr[3], addr[4], addr[5]]; | ||
} | ||
|
||
- (NSString *) nameOrAddress{ | ||
if (name) return name; | ||
return [BTDevice stringForAddress:&address]; | ||
} | ||
|
||
- (BluetoothDeviceType) deviceType{ | ||
switch (classOfDevice) { | ||
case kCODHID: | ||
return kBluetoothDeviceTypeHID; | ||
case kCODZeeMote: | ||
return kBluetoothDeviceTypeZeeMote; | ||
default: | ||
return kBluetoothDeviceTypeGeneric; | ||
} | ||
} | ||
- (NSString *) toString{ | ||
return [NSString stringWithFormat:@"Device addr %@ name %@ COD %x", [BTDevice stringForAddress:&address], name, classOfDevice]; | ||
} | ||
|
||
- (void)dealloc { | ||
[name release]; | ||
[super dealloc]; | ||
} | ||
|
||
@end |
Oops, something went wrong.