Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KAA-292: implement Objective-C SDK; add ability to generate Objective…
…-C SDK dynamically.
- Loading branch information
Showing
361 changed files
with
37,792 additions
and
34 deletions.
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
This file was deleted.
Oops, something went wrong.
2,426 changes: 2,426 additions & 0 deletions
2,426
client/client-multi/client-objective-c/Kaa.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
...lient-multi/client-objective-c/Kaa.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
client/client-multi/client-objective-c/Kaa.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
client/client-multi/client-objective-c/Kaa.xcworkspace/xcshareddata/Kaa.xcscmblueprint
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,30 @@ | ||
{ | ||
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "0CA4F3CFE55A12407B44C8109D3620D699EFEF07", | ||
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { | ||
|
||
}, | ||
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { | ||
"0CA4F3CFE55A12407B44C8109D3620D699EFEF07" : 0, | ||
"B401B74FA4825A3AF8BEAD942EB222B09AC26B7C" : 0 | ||
}, | ||
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "8FE1BCB9-AB7D-4D85-B95B-A4B1D479C183", | ||
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { | ||
"0CA4F3CFE55A12407B44C8109D3620D699EFEF07" : "kaa-client-objective-c", | ||
"B401B74FA4825A3AF8BEAD942EB222B09AC26B7C" : "..\/.." | ||
}, | ||
"DVTSourceControlWorkspaceBlueprintNameKey" : "Kaa", | ||
"DVTSourceControlWorkspaceBlueprintVersion" : 204, | ||
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "Kaa.xcworkspace", | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ | ||
{ | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:abohomol\/kaa-client-objective-c.git", | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "0CA4F3CFE55A12407B44C8109D3620D699EFEF07" | ||
}, | ||
{ | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:kaaproject\/kaa.git", | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", | ||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "B401B74FA4825A3AF8BEAD942EB222B09AC26B7C" | ||
} | ||
] | ||
} |
34 changes: 34 additions & 0 deletions
34
client/client-multi/client-objective-c/Kaa/AbstractConfigurationManager.h
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,34 @@ | ||
/* | ||
* Copyright 2014-2015 CyberVision, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "ConfigurationCommon.h" | ||
#import "KaaClientProperties.h" | ||
#import "ConfigurationDeserializer.h" | ||
#import "KaaClientState.h" | ||
#import "ExecutorContext.h" | ||
|
||
@interface AbstractConfigurationManager : NSObject <ConfigurationManager> | ||
|
||
@property(nonatomic,strong,readonly) ConfigurationDeserializer *deserializer; | ||
|
||
- (instancetype)initWithClientProperties:(KaaClientProperties *)properties state:(id<KaaClientState>)state andExecutorContext:(id<ExecutorContext>)context; | ||
|
||
- (NSData *)getConfigurationData; | ||
|
||
- (NSData *)getDefaultConfiguratioData; | ||
|
||
@end |
143 changes: 143 additions & 0 deletions
143
client/client-multi/client-objective-c/Kaa/AbstractConfigurationManager.m
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,143 @@ | ||
/* | ||
* Copyright 2014-2015 CyberVision, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "AbstractConfigurationManager.h" | ||
#import "KaaLogging.h" | ||
|
||
#define TAG @"AbstractConfigurationManager >>>" | ||
|
||
@interface AbstractConfigurationManager () | ||
|
||
@property(nonatomic,strong) KaaClientProperties *properties; | ||
@property(nonatomic,strong) id<KaaClientState> state; | ||
@property(nonatomic,strong) id<ConfigurationStorage> storage; | ||
@property(nonatomic,strong) NSData *configurationData; | ||
@property(nonatomic,strong) id<ExecutorContext> executorContext; | ||
|
||
@property(strong) NSMutableSet *delegates; | ||
@property(strong) NSLock *delegatesLock; | ||
|
||
- (NSData *)loadConfigurationData; | ||
|
||
@end | ||
|
||
@implementation AbstractConfigurationManager | ||
|
||
- (instancetype)initWithClientProperties:(KaaClientProperties *)properties state:(id<KaaClientState>)state andExecutorContext:(id<ExecutorContext>)context { | ||
self = [super init]; | ||
if (self) { | ||
self.delegates = [NSMutableSet set]; | ||
self.properties = properties; | ||
self.state = state; | ||
_deserializer = [[ConfigurationDeserializer alloc] initWithExecutorContext:context]; | ||
self.executorContext = context; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)initiate { | ||
[self getConfigurationData]; | ||
DDLogDebug(@"%@ Configuration manager init completed!", TAG); | ||
} | ||
|
||
- (void)addDelegate:(id<ConfigurationDelegate>)delegate { | ||
if (delegate) { | ||
DDLogVerbose(@"%@ Adding delegate %@", TAG, delegate); | ||
[self.delegatesLock lock]; | ||
[self.delegates addObject:delegate]; | ||
[self.delegatesLock unlock]; | ||
} else { | ||
[NSException raise:NSInvalidArgumentException format:@"Can't add nil delegate"]; | ||
} | ||
} | ||
|
||
- (void)removeDelegate:(id<ConfigurationDelegate>)delegate { | ||
if (delegate) { | ||
DDLogVerbose(@"%@ Removing delegate", TAG); | ||
[self.delegatesLock lock]; | ||
[self.delegates removeObject:delegate]; | ||
[self.delegatesLock unlock]; | ||
} else { | ||
[NSException raise:NSInvalidArgumentException format:@"Can't remove nil delegate"]; | ||
|
||
} | ||
} | ||
|
||
- (void)processConfigurationData:(NSData *)data fullResync:(BOOL)fullResync { | ||
if (fullResync) { | ||
self.configurationData = data; | ||
DDLogVerbose(@"%@ Received configuration data: %@", TAG, self.configurationData); | ||
if (self.storage) { | ||
DDLogDebug(@"%@ Persisting configuration data from storage: %@", TAG, self.storage); | ||
[self.storage saveConfiguration:self.configurationData]; | ||
DDLogDebug(@"%@ Persisted configuration data from storage: %@", TAG, self.storage); | ||
} | ||
[self.delegatesLock lock]; | ||
[_deserializer notify:self.delegates withData:self.configurationData]; | ||
[self.delegatesLock unlock]; | ||
} else { | ||
DDLogWarn(@"%@ Only full resync delta is supported!", TAG); | ||
} | ||
} | ||
|
||
- (EndpointObjectHash *)getConfigurationHash { | ||
return [EndpointObjectHash fromSHA1:[self getConfigurationData]]; | ||
} | ||
|
||
- (void)setConfigurationStorage:(id<ConfigurationStorage>)storage { | ||
self.storage = storage; | ||
} | ||
|
||
- (NSData *)loadConfigurationData { | ||
if (self.storage) { | ||
if ([self.state isConfigurationVersionUpdated]) { | ||
DDLogDebug(@"%@ Clearing old configuration data from storage: %@", TAG, self.storage); | ||
@try { | ||
[self.storage clearConfiguration]; | ||
} | ||
@catch (NSException *exception) { | ||
DDLogError(@"%@ Failed to clear configuration from storage: %@", TAG, exception); | ||
} | ||
} else { | ||
DDLogDebug(@"%@ Loading configuration data from storage: %@", TAG, self.storage); | ||
@try { | ||
self.configurationData = [self.storage loadConfiguration]; | ||
} | ||
@catch (NSException *exception) { | ||
DDLogError(@"%@ Failed to load configuration from storage: %@", TAG, exception); | ||
} | ||
} | ||
} | ||
if (!self.configurationData) { | ||
DDLogDebug(@"%@ Loading configuration data from defaults: %@", TAG, self.storage); | ||
self.configurationData = [self getDefaultConfiguratioData]; | ||
} | ||
DDLogVerbose(@"%@ Loaded configuration data: %@", TAG, self.configurationData); | ||
return self.configurationData; | ||
} | ||
|
||
- (NSData *)getConfigurationData { | ||
if (!self.configurationData) { | ||
self.configurationData = [self loadConfigurationData]; | ||
} | ||
return self.configurationData; | ||
} | ||
|
||
- (NSData *)getDefaultConfiguratioData { | ||
return [self.properties defaultConfigData]; | ||
} | ||
|
||
@end |
29 changes: 29 additions & 0 deletions
29
client/client-multi/client-objective-c/Kaa/AbstractExecutorContext.h
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,29 @@ | ||
/* | ||
* Copyright 2014-2015 CyberVision, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "ExecutorContext.h" | ||
#import "TimeCommons.h" | ||
|
||
@interface AbstractExecutorContext : NSObject <ExecutorContext> | ||
|
||
@property (nonatomic) NSInteger timeOut; | ||
@property (nonatomic) TimeUnit timeUnit; | ||
|
||
- (instancetype)initWithTimeOut:(NSInteger)timeOut andTimeUnit:(TimeUnit)timeUnit; | ||
- (void)shutDownExecutor:(NSOperationQueue*)queue; | ||
|
||
@end |
93 changes: 93 additions & 0 deletions
93
client/client-multi/client-objective-c/Kaa/AbstractExecutorContext.m
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,93 @@ | ||
/* | ||
* Copyright 2014-2015 CyberVision, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
|
||
@import QuartzCore; | ||
#import "AbstractExecutorContext.h" | ||
#import "KaaLogging.h" | ||
|
||
#define TAG @"AbstractExecutorContext >>>" | ||
|
||
#define DEFAULT_TIMEOUT (5) | ||
#define DEFAULT_TIMEUNIT TIME_UNIT_SECONDS | ||
|
||
@implementation AbstractExecutorContext | ||
|
||
|
||
- (instancetype)init { | ||
return [self initWithTimeOut:DEFAULT_TIMEOUT andTimeUnit:DEFAULT_TIMEUNIT]; | ||
} | ||
|
||
- (instancetype) initWithTimeOut:(NSInteger)timeOut andTimeUnit:(TimeUnit)timeUnit { | ||
self = [super init]; | ||
if (self) { | ||
self.timeOut = timeOut; | ||
self.timeUnit = timeUnit; | ||
} | ||
return self; | ||
} | ||
|
||
- (void) shutDownExecutor:(NSOperationQueue*)queue { | ||
|
||
if (!queue) { | ||
DDLogWarn(@"%@ Can't shutdown empty executor", TAG); | ||
return; | ||
} | ||
|
||
DDLogDebug(@"%@ Shutdown executor service", TAG); | ||
[queue cancelAllOperations]; | ||
DDLogDebug(@"%@ Waiting for executor service to shutdown for %ld %u", TAG, (long)self.timeOut, self.timeUnit); | ||
@try { | ||
double fixedTime = CACurrentMediaTime(); | ||
while ([queue operationCount] && (CACurrentMediaTime() < (fixedTime + self.timeOut))) { | ||
sleep(100); | ||
} | ||
} | ||
@catch (NSException *exception) { | ||
DDLogWarn(@"%@ Interrupted while waiting for executor to shutdown. Reason: %@", TAG, exception.reason); | ||
} | ||
} | ||
|
||
- (NSOperationQueue *)getLifeCycleExecutor { | ||
[NSException raise:NSInternalInconsistencyException format:@"Not implemented in abstract class"]; | ||
return nil; | ||
} | ||
|
||
- (NSOperationQueue *)getApiExecutor { | ||
[NSException raise:NSInternalInconsistencyException format:@"Not implemented in abstract class"]; | ||
return nil; | ||
} | ||
|
||
- (NSOperationQueue *)getCallbackExecutor { | ||
[NSException raise:NSInternalInconsistencyException format:@"Not implemented in abstract class"]; | ||
return nil; | ||
} | ||
|
||
- (dispatch_queue_t)getSheduledExecutor { | ||
[NSException raise:NSInternalInconsistencyException format:@"Not implemented in abstract class"]; | ||
return nil; | ||
} | ||
|
||
- (void) stop { | ||
[NSException raise:NSInternalInconsistencyException format:@"Not implemented in abstract class"]; | ||
} | ||
|
||
- (void) initiate { | ||
[NSException raise:NSInternalInconsistencyException format:@"Not implemented in abstract class"]; | ||
} | ||
|
||
|
||
@end |
Oops, something went wrong.