CB-10238 Move device-plugin out from cordovalib to the plugin repository
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/46d87eb7 Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/46d87eb7 Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/46d87eb7 Branch: refs/heads/master Commit: 46d87eb7db247d8c3448aba71f8fc3f0f7909c68 Parents: 599acc5 Author: Tobias Bocanegra <[email protected]> Authored: Mon Dec 21 16:14:09 2015 -0800 Committer: Tobias Bocanegra <[email protected]> Committed: Mon Dec 21 16:14:09 2015 -0800 ---------------------------------------------------------------------- CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 8 -- CordovaLib/CordovaLib/Classes/Commands/CDV.h | 5 +- .../CordovaLib/Classes/Commands/CDVDevice.h | 29 ------ .../CordovaLib/Classes/Commands/CDVDevice.m | 102 ------------------- 4 files changed, 2 insertions(+), 142 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/46d87eb7/CordovaLib/CordovaLib.xcodeproj/project.pbxproj ---------------------------------------------------------------------- diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj index 4392997..43935cd 100644 --- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj +++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj @@ -26,8 +26,6 @@ 70BD67A818FFA12D00A1EFCF /* CDVConsole.h in Headers */ = {isa = PBXBuildFile; fileRef = 70BD678118FFA12D00A1EFCF /* CDVConsole.h */; settings = {ATTRIBUTES = (Public, ); }; }; 70BD67A918FFA12D00A1EFCF /* CDVConsole.m in Sources */ = {isa = PBXBuildFile; fileRef = 70BD678218FFA12D00A1EFCF /* CDVConsole.m */; }; 70BD67AA18FFA12D00A1EFCF /* CDVDebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 70BD678318FFA12D00A1EFCF /* CDVDebug.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 70BD67AB18FFA12D00A1EFCF /* CDVDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 70BD678418FFA12D00A1EFCF /* CDVDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 70BD67AC18FFA12D00A1EFCF /* CDVDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 70BD678518FFA12D00A1EFCF /* CDVDevice.m */; }; 70BD67AD18FFA12D00A1EFCF /* CDVInvokedUrlCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 70BD678618FFA12D00A1EFCF /* CDVInvokedUrlCommand.h */; settings = {ATTRIBUTES = (Public, ); }; }; 70BD67AE18FFA12D00A1EFCF /* CDVInvokedUrlCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 70BD678718FFA12D00A1EFCF /* CDVInvokedUrlCommand.m */; }; 70BD67AF18FFA12D00A1EFCF /* CDVJSON.h in Headers */ = {isa = PBXBuildFile; fileRef = 70BD678818FFA12D00A1EFCF /* CDVJSON.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -80,8 +78,6 @@ 70BD678118FFA12D00A1EFCF /* CDVConsole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVConsole.h; sourceTree = "<group>"; }; 70BD678218FFA12D00A1EFCF /* CDVConsole.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVConsole.m; sourceTree = "<group>"; }; 70BD678318FFA12D00A1EFCF /* CDVDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVDebug.h; sourceTree = "<group>"; }; - 70BD678418FFA12D00A1EFCF /* CDVDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVDevice.h; sourceTree = "<group>"; }; - 70BD678518FFA12D00A1EFCF /* CDVDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVDevice.m; sourceTree = "<group>"; }; 70BD678618FFA12D00A1EFCF /* CDVInvokedUrlCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVInvokedUrlCommand.h; sourceTree = "<group>"; }; 70BD678718FFA12D00A1EFCF /* CDVInvokedUrlCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVInvokedUrlCommand.m; sourceTree = "<group>"; }; 70BD678818FFA12D00A1EFCF /* CDVJSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVJSON.h; sourceTree = "<group>"; }; @@ -214,8 +210,6 @@ 70BD678118FFA12D00A1EFCF /* CDVConsole.h */, 70BD678218FFA12D00A1EFCF /* CDVConsole.m */, 70BD678318FFA12D00A1EFCF /* CDVDebug.h */, - 70BD678418FFA12D00A1EFCF /* CDVDevice.h */, - 70BD678518FFA12D00A1EFCF /* CDVDevice.m */, 70BD678618FFA12D00A1EFCF /* CDVInvokedUrlCommand.h */, 70BD678718FFA12D00A1EFCF /* CDVInvokedUrlCommand.m */, 70BD678818FFA12D00A1EFCF /* CDVJSON.h */, @@ -259,7 +253,6 @@ 70BD679D18FFA12D00A1EFCF /* CDV.h in Headers */, 70BD67AD18FFA12D00A1EFCF /* CDVInvokedUrlCommand.h in Headers */, 70BD679718FFA12D00A1EFCF /* CDVBridge.h in Headers */, - 70BD67AB18FFA12D00A1EFCF /* CDVDevice.h in Headers */, 70BD67AF18FFA12D00A1EFCF /* CDVJSON.h in Headers */, 70BD67AA18FFA12D00A1EFCF /* CDVDebug.h in Headers */, 70BD679B18FFA12D00A1EFCF /* CDVWebViewDelegate.h in Headers */, @@ -339,7 +332,6 @@ 70BD67B018FFA12D00A1EFCF /* CDVJSON.m in Sources */, 70BD67A318FFA12D00A1EFCF /* CDVCommandQueue.m in Sources */, 70BD67B818FFA12D00A1EFCF /* NSData+Base64.m in Sources */, - 70BD67AC18FFA12D00A1EFCF /* CDVDevice.m in Sources */, 70BD679C18FFA12D00A1EFCF /* CDVWebViewDelegate.m in Sources */, 70BD679818FFA12D00A1EFCF /* CDVBridge.m in Sources */, 70BD67BC18FFA12D00A1EFCF /* ShellUtils.m in Sources */, http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/46d87eb7/CordovaLib/CordovaLib/Classes/Commands/CDV.h ---------------------------------------------------------------------- diff --git a/CordovaLib/CordovaLib/Classes/Commands/CDV.h b/CordovaLib/CordovaLib/Classes/Commands/CDV.h index 480dc94..ff6ca2c 100644 --- a/CordovaLib/CordovaLib/Classes/Commands/CDV.h +++ b/CordovaLib/CordovaLib/Classes/Commands/CDV.h @@ -6,9 +6,9 @@ to you 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 @@ -24,4 +24,3 @@ #import "CDVPluginResult.h" #import "CDVInvokedUrlCommand.h" #import "CDVPlugin.h" -#import "CDVDevice.h" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/46d87eb7/CordovaLib/CordovaLib/Classes/Commands/CDVDevice.h ---------------------------------------------------------------------- diff --git a/CordovaLib/CordovaLib/Classes/Commands/CDVDevice.h b/CordovaLib/CordovaLib/Classes/Commands/CDVDevice.h deleted file mode 100644 index 81cffb7..0000000 --- a/CordovaLib/CordovaLib/Classes/Commands/CDVDevice.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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 "CDVPlugin.h" - -@interface CDVDevice : CDVPlugin -{} - -+ (NSString*)cordovaVersion; - -- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command; - -@end http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/46d87eb7/CordovaLib/CordovaLib/Classes/Commands/CDVDevice.m ---------------------------------------------------------------------- diff --git a/CordovaLib/CordovaLib/Classes/Commands/CDVDevice.m b/CordovaLib/CordovaLib/Classes/Commands/CDVDevice.m deleted file mode 100644 index 0636d95..0000000 --- a/CordovaLib/CordovaLib/Classes/Commands/CDVDevice.m +++ /dev/null @@ -1,102 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - */ - -#include <sys/types.h> -#include <sys/sysctl.h> - -#import "CDVDevice.h" -#import "CDVAvailability.h" - -#define SYSTEM_VERSION_PLIST @"/System/Library/CoreServices/SystemVersion.plist" - -@implementation CDVDevice - -- (NSString*)modelVersion -{ - size_t size; - - sysctlbyname("hw.machine", NULL, &size, NULL, 0); - char* machine = malloc(size); - sysctlbyname("hw.machine", machine, &size, NULL, 0); - NSString* modelVersion = [NSString stringWithUTF8String:machine]; - free(machine); - - return modelVersion; -} - -- (NSString*)uniqueAppInstanceIdentifier -{ - NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; - static NSString* UUID_KEY = @"CDVUUID"; - - NSString* app_uuid = [userDefaults stringForKey:UUID_KEY]; - - if (app_uuid == nil) { - CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault); - CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef); - - app_uuid = [NSString stringWithString:(__bridge NSString*)uuidString]; - [userDefaults setObject:app_uuid forKey:UUID_KEY]; - [userDefaults synchronize]; - - CFRelease(uuidString); - CFRelease(uuidRef); - } - - return app_uuid; -} - -- (NSString*) platform -{ - return [[NSDictionary dictionaryWithContentsOfFile:SYSTEM_VERSION_PLIST] objectForKey:@"ProductName"]; -} - -- (NSString*)systemVersion -{ - return [[NSDictionary dictionaryWithContentsOfFile:SYSTEM_VERSION_PLIST] objectForKey:@"ProductVersion"]; -} - -- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command -{ - NSDictionary* deviceProperties = [self deviceProperties]; - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties]; - - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; -} - -- (NSDictionary*)deviceProperties -{ - NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4]; - - [devProps setObject:[self modelVersion] forKey:@"model"]; - [devProps setObject:[self platform] forKey:@"platform"]; - [devProps setObject:[self systemVersion] forKey:@"version"]; - [devProps setObject:[self uniqueAppInstanceIdentifier] forKey:@"uuid"]; - [devProps setObject:[[self class] cordovaVersion] forKey:@"cordova"]; - - NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps]; - return devReturn; -} - -+ (NSString*)cordovaVersion -{ - return CDV_VERSION; -} - -@end --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
