Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
[#280] added bitcoin.getApplication
Browse files Browse the repository at this point in the history
  • Loading branch information
mackuba committed Feb 24, 2014
1 parent 7b7519e commit 9a86761
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions Hive/Backend/HIApplicationsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extern const NSInteger HIApplicationManagerInvalidAppFileError;
- (BOOL)requestLocalAppInstallation:(NSURL *)applicationURL showAppsPage:(BOOL)showAppsPage error:(NSError **)error;
- (void)requestRemoteAppInstallation:(NSURL *)remoteURL onCompletion:(void (^)(BOOL, NSError *))completionBlock;
- (BOOL)hasApplicationOfId:(NSString *)applicationId;
- (HIApplication *)getApplicationById:(NSString *)applicationId;
- (NSDictionary *)applicationMetadata:(NSURL *)applicationPath;
- (void)preinstallApps;
- (void)rebuildAppsList;
Expand Down
7 changes: 7 additions & 0 deletions Hive/Backend/HIApplicationsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ - (BOOL)hasApplicationOfId:(NSString *)applicationId {
return (count > 0);
}

- (HIApplication *)getApplicationById:(NSString *)applicationId {
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:HIApplicationEntity];
request.predicate = [NSPredicate predicateWithFormat:@"id == %@", applicationId];

return [[DBM executeFetchRequest:request error:NULL] firstObject];
}

- (void)removeAllApps {
NSError *error = nil;
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:HIApplicationEntity];
Expand Down
19 changes: 18 additions & 1 deletion Hive/Controllers/HIAppRuntimeBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MINOR version must be incremented when new API features are added
// MAJOR version must be incremented when existing API features are changed incompatibly.
static const NSUInteger API_VERSION_MAJOR = 0;
static const NSUInteger API_VERSION_MINOR = 1;
static const NSUInteger API_VERSION_MINOR = 2;

static NSString * const kHIAppRuntimeBridgeErrorDomain = @"HIAppRuntimeBridgeErrorDomain";
static const NSInteger kHIAppRuntimeBridgeParsingError = -1000;
Expand Down Expand Up @@ -76,6 +76,7 @@ + (NSDictionary *)selectorMap {
@"getSystemInfoWithCallback:": @"getSystemInfo",
@"makeProxiedRequestToURL:options:": @"makeRequest",
@"installAppFromURL:callback:": @"installApp",
@"applicationDataById:callback:": @"getApplication",
@"addExchangeRateListener:": @"addExchangeRateListener",
@"removeExchangeRateListener:": @"removeExchangeRateListener",
@"updateExchangeRateForCurrency:": @"updateExchangeRate",
Expand Down Expand Up @@ -246,6 +247,22 @@ - (void)transactionWithHash:(NSString *)hash callback:(WebScriptObject *)callbac
[self callCallbackMethod:callback withArguments:&jsonValue count:1];
}

- (void)applicationDataById:(NSString *)applicationId callback:(WebScriptObject *)callback {
ValidateArgument(NSString, applicationId);
ValidateArgument(WebScriptObject, callback);

NSDictionary *manifest = [[[HIApplicationsManager sharedManager] getApplicationById:applicationId] manifest];
JSValueRef value;

if (manifest) {
value = [self valueObjectFromDictionary:manifest];
} else {
value = JSValueMakeNull(self.context);
}

[self callCallbackMethod:callback withArguments:&value count:1];
}

- (void)getUserInformationWithCallback:(WebScriptObject *)callback {

ValidateArgument(WebScriptObject, callback);
Expand Down

0 comments on commit 9a86761

Please sign in to comment.