Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-17806] (3_4_X) Cleanup #6227

Merged
merged 7 commits into from
Oct 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion iphone/Classes/AccelerometerModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
#import "TiModule.h"

#ifdef USE_TI_ACCELEROMETER
#import <CoreMotion/CoreMotion.h>

@interface AccelerometerModule : TiModule<UIAccelerometerDelegate> {

@private
CMMotionManager* _motionManager;
NSOperationQueue* _motionQueue;
CFAbsoluteTime oldTime;
}

@end
Expand Down
70 changes: 50 additions & 20 deletions iphone/Classes/AccelerometerModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,70 @@

@implementation AccelerometerModule

-(void)dealloc
{
[self stopGeneratingEvents];
[super dealloc];
}

-(NSString*)apiName
{
return @"Ti.Accelerometer";
}

-(void)_listenerAdded:(NSString *)type count:(int)count

-(void)startGeneratingEvents
{
if (count == 1 && [type isEqualToString:@"update"])
{
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
}
if (_motionManager == nil) {
_motionManager = [[CMMotionManager alloc] init];
if (_motionManager.isAccelerometerAvailable) {
_motionQueue = [[NSOperationQueue alloc] init];
_motionManager.accelerometerUpdateInterval = 1.0/10.0;
oldTime = CFAbsoluteTimeGetCurrent();
[_motionManager startAccelerometerUpdatesToQueue:_motionQueue withHandler:^(CMAccelerometerData *accelerometerData, NSError *error){
if (error == nil) {
NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:
NUMDOUBLE(accelerometerData.acceleration.x), @"x",
NUMDOUBLE(accelerometerData.acceleration.y), @"y",
NUMDOUBLE(accelerometerData.acceleration.z), @"z",
NUMLONGLONG((CFAbsoluteTimeGetCurrent() - oldTime)*1000),@"timestamp",
nil];
[self fireEvent:@"update" withObject:event];
} else {
DebugLog(@"Error in event - %@",[TiUtils messageFromError:error]);
}
}];

} else {
DebugLog(@"Accelerometer is Unavailable on this device");
RELEASE_TO_NIL(_motionManager);
}
}
}

-(void)_listenerRemoved:(NSString *)type count:(int)count
-(void)stopGeneratingEvents
{
if (count == 0 && [type isEqualToString:@"update"])
{
[[UIAccelerometer sharedAccelerometer] setDelegate:nil];
}
if (_motionManager != nil) {
[_motionManager stopAccelerometerUpdates];
RELEASE_TO_NIL_AUTORELEASE(_motionQueue);
RELEASE_TO_NIL_AUTORELEASE(_motionManager);
}
}

#pragma mark Accelerometer Delegate

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
-(void)_listenerAdded:(NSString *)type count:(int)count
{
NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:
NUMFLOAT([acceleration x]), @"x",
NUMFLOAT([acceleration y]), @"y",
NUMFLOAT([acceleration z]), @"z",
NUMLONGLONG([acceleration timestamp] * 1000), @"timestamp",
nil];
[self fireEvent:@"update" withObject:event];
if ( (count == 1) && [type isEqualToString:@"update"] ) {
[self startGeneratingEvents];
}

}

-(void)_listenerRemoved:(NSString *)type count:(int)count
{
if ( (count == 0) && [type isEqualToString:@"update"] ) {
[self stopGeneratingEvents];
}
}

@end

Expand Down
13 changes: 12 additions & 1 deletion iphone/Classes/AudioStreamer/AudioStreamerCUR.m
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ - (BOOL)openReadStream
//
if( [[url absoluteString] rangeOfString:@"https"].location != NSNotFound )
{
/*---Titanium Modifications start---*/
/*
* kCFStreamSSLAllowsExpiredCertificates, kCFStreamSSLAllowsExpiredRoots, kCFStreamSSLValidatesCertificateChain
* deprecated in iOS4. Use kCFStreamSSLValidatesCertificateChain to disable certificate chain validation.
NSDictionary *sslSettings =
[NSDictionary dictionaryWithObjectsAndKeys:
(NSString *)kCFStreamSocketSecurityLevelNegotiatedSSL, kCFStreamSSLLevel,
Expand All @@ -544,7 +548,14 @@ - (BOOL)openReadStream
[NSNumber numberWithBool:NO], kCFStreamSSLValidatesCertificateChain,
[NSNull null], kCFStreamSSLPeerName,
nil];

*/
NSDictionary *sslSettings =
[NSDictionary dictionaryWithObjectsAndKeys:
(NSString *)kCFStreamSocketSecurityLevelNegotiatedSSL, kCFStreamSSLLevel,
[NSNumber numberWithBool:NO], kCFStreamSSLValidatesCertificateChain,
[NSNull null], kCFStreamSSLPeerName,
nil];
/*---Titanium Modifications End---*/
CFReadStreamSetProperty(stream, kCFStreamPropertySSLSettings, sslSettings);
}

Expand Down
2 changes: 0 additions & 2 deletions iphone/Classes/TiApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ TI_INLINE void waitForMemoryPanicCleared() //WARNING: This must never be run o
*/
-(NSString*)sessionId;

-(KrollBridge*)krollBridge;

-(void)beginBackgrounding;
-(void)endBackgrounding;

Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiBindingEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void TiBindingEventSetBubbles(TiBindingEvent event, bool bubbles)
//TIMOB-11691. Ensure that tableviewrowproxy modifies the event object before passing it along.
if ([currentTarget respondsToSelector:@selector(createEventObject:)]) {
NSDictionary *curPayload = event->payloadDictionary;
NSDictionary *modifiedPayload = [currentTarget createEventObject:curPayload];
NSDictionary *modifiedPayload = [currentTarget performSelector:@selector(createEventObject:) withObject:curPayload];
[event->payloadDictionary release];
event->payloadDictionary = [modifiedPayload copy];
}
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiBindingTiValue.m
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ TiValueRef TiBindingTiValueFromNSObject(TiContextRef jsContext, NSObject * obj)
}
if ([obj isKindOfClass:[NSString class]])
{
TiStringRef jsString = TiStringCreateWithCFString((CFStringRef) obj);
TiStringRef jsString = TiStringCreateWithCFString((CFStringRef) (NSString*)obj);
TiValueRef result = TiValueMakeString(jsContext,jsString);
TiStringRelease(jsString);
return result;
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@
-(void)unregisterContext:(id<TiEvaluator>)context forToken:(NSString*)token;
-(id<TiEvaluator>)contextForToken:(NSString*)token;

-(KrollBridge*)krollBridge;

@end
6 changes: 6 additions & 0 deletions iphone/Classes/TiHost.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ -(void)unregisterContext:(id<TiEvaluator>)context forToken:(NSString*)token
[contexts removeObjectForKey:token];
}

-(KrollBridge*)krollBridge
{
//For subclasses
return nil;
}

-(id) moduleNamed:(NSString*)name context:(id<TiEvaluator>)context
{
TiModule *m = [modules objectForKey:name];
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiMediaAudioPlayerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ -(void)start:(id)args
// indicate we're going to start playing
if (![[TiMediaAudioSession sharedSession] canPlayback]) {
[self throwException:@"Improper audio session mode for playback"
subreason:[[NSNumber numberWithUnsignedInt:[[TiMediaAudioSession sharedSession] sessionMode]] description]
subreason:[[TiMediaAudioSession sharedSession] sessionMode]
location:CODELOCATION];
}

Expand Down
10 changes: 6 additions & 4 deletions iphone/Classes/TiMediaAudioRecorderProxy.mm
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,12 @@ -(void)audioInterruptionBegin:(NSNotification*)note

-(void)audioInterruptionEnd:(NSNotification*)note
{
if ([self paused])
{
[self resume:nil];
}
if ([self paused]) {
id resumeObject = [[note userInfo] objectForKey:@"resume"];
if ([TiUtils boolValue:resumeObject def:NO]) {
[self resume:nil];
}
}
}

@end
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiMediaSoundProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ -(void)play:(id)args
// indicate we're going to start playback
if (![[TiMediaAudioSession sharedSession] canPlayback]) {
[self throwException:@"Improper audio session mode for playback"
subreason:[[NSNumber numberWithUnsignedInt:[[TiMediaAudioSession sharedSession] sessionMode]] description]
subreason:[[TiMediaAudioSession sharedSession] sessionMode]
location:CODELOCATION];
}

Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/TiMediaVideoPlayerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,8 @@ -(void)handlePlaybackStateChangeNotification:(NSNotification*)note
case MPMoviePlaybackStatePlaying:
playing = YES;
break;
default:
break;
}
}

Expand Down
4 changes: 2 additions & 2 deletions iphone/Classes/TiNetworkTCPSocketProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ -(CFSocketNativeHandle)getHandleFromStream:(NSStream*)stream
CFDataRef remoteSocketData;

if ([stream isKindOfClass:[NSInputStream class]]) {
remoteSocketData = (CFDataRef)CFReadStreamCopyProperty((CFReadStreamRef)stream, kCFStreamPropertySocketNativeHandle);
remoteSocketData = (CFDataRef)CFReadStreamCopyProperty((CFReadStreamRef)(NSInputStream*)stream, kCFStreamPropertySocketNativeHandle);
}
else {
remoteSocketData = (CFDataRef)CFWriteStreamCopyProperty((CFWriteStreamRef)stream, kCFStreamPropertySocketNativeHandle);
remoteSocketData = (CFDataRef)CFWriteStreamCopyProperty((CFWriteStreamRef)(NSOutputStream*)stream, kCFStreamPropertySocketNativeHandle);
}

if (remoteSocketData == NULL) {
Expand Down
8 changes: 8 additions & 0 deletions iphone/iphone/Titanium.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@
84C3870217417CB800970D26 /* TiSelectedCellbackgroundView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84C3870117417CB800970D26 /* TiSelectedCellbackgroundView.m */; };
84C3870317417CB800970D26 /* TiSelectedCellbackgroundView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84C3870117417CB800970D26 /* TiSelectedCellbackgroundView.m */; };
84C3870417417CB800970D26 /* TiSelectedCellbackgroundView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84C3870117417CB800970D26 /* TiSelectedCellbackgroundView.m */; };
84D4CA1419EF0B3D009131F8 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84D4CA1319EF0B3D009131F8 /* CoreMotion.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
84D4CA1519EF0B4D009131F8 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84D4CA1319EF0B3D009131F8 /* CoreMotion.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
84D4CA1619EF0B5A009131F8 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84D4CA1319EF0B3D009131F8 /* CoreMotion.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
84D541A31460B2E0005338D1 /* TiDOMNotationProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D541A21460B2DF005338D1 /* TiDOMNotationProxy.m */; };
84D541A41460B2E0005338D1 /* TiDOMNotationProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D541A21460B2DF005338D1 /* TiDOMNotationProxy.m */; };
84D541A51460B2E0005338D1 /* TiDOMNotationProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D541A21460B2DF005338D1 /* TiDOMNotationProxy.m */; };
Expand Down Expand Up @@ -1427,6 +1430,7 @@
84BBA58716570F90006B8C22 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
84C3870017417CB800970D26 /* TiSelectedCellbackgroundView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiSelectedCellbackgroundView.h; sourceTree = "<group>"; };
84C3870117417CB800970D26 /* TiSelectedCellbackgroundView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TiSelectedCellbackgroundView.m; sourceTree = "<group>"; };
84D4CA1319EF0B3D009131F8 /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
84D541A11460B2DF005338D1 /* TiDOMNotationProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiDOMNotationProxy.h; sourceTree = "<group>"; };
84D541A21460B2DF005338D1 /* TiDOMNotationProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TiDOMNotationProxy.m; sourceTree = "<group>"; };
84D541A61460B3C7005338D1 /* TiDOMEntityProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiDOMEntityProxy.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1546,6 +1550,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
84D4CA1619EF0B5A009131F8 /* CoreMotion.framework in Frameworks */,
312E36C1190B06D9008EAB8D /* libAPSAnalytics.a in Frameworks */,
841CCAD11807395C00C8DB76 /* CoreText.framework in Frameworks */,
D93DAA6D16CBFD7100AD64C9 /* EventKit.framework in Frameworks */,
Expand Down Expand Up @@ -1585,6 +1590,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
84D4CA1519EF0B4D009131F8 /* CoreMotion.framework in Frameworks */,
312E36C2190B06D9008EAB8D /* libAPSAnalytics.a in Frameworks */,
841CCAD21807396E00C8DB76 /* CoreText.framework in Frameworks */,
D93DAA6B16CBFD6400AD64C9 /* EventKit.framework in Frameworks */,
Expand Down Expand Up @@ -1623,6 +1629,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
84D4CA1419EF0B3D009131F8 /* CoreMotion.framework in Frameworks */,
312E36C3190B06D9008EAB8D /* libAPSAnalytics.a in Frameworks */,
841CCAD31807397800C8DB76 /* CoreText.framework in Frameworks */,
D93DAA6916CBFD5600AD64C9 /* EventKit.framework in Frameworks */,
Expand Down Expand Up @@ -2733,6 +2740,7 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
84D4CA1319EF0B3D009131F8 /* CoreMotion.framework */,
B606EF5F190B42FB00663EFC /* libAPSHTTPClient.a */,
841CCAD01807395C00C8DB76 /* CoreText.framework */,
D93DAA6716CBFD5600AD64C9 /* EventKit.framework */,
Expand Down