Skip to content

Commit

Permalink
Merge branch 'feature/refactor' into master
Browse files Browse the repository at this point in the history
# Conflicts:
#	build/build.xml
  • Loading branch information
mateo-kozomara committed Oct 13, 2017
2 parents 54615da + e74d44f commit 5e94e07
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 201 deletions.
2 changes: 1 addition & 1 deletion android/lib/build.gradle
Expand Up @@ -28,5 +28,5 @@ dependencies {
})

testCompile 'junit:junit:4.12'
compile files('libs/FlashRuntimeExtensions.jar')

}
Binary file modified bin/AirNetworkInfo.ane
Binary file not shown.
27 changes: 16 additions & 11 deletions build/extension.xml
@@ -1,15 +1,20 @@
<!--////////////////////////////////////////////////////////////////////////////////////////////////////
// ADOBE SYSTEMS INCORPORATED //
// Copyright 2011 Adobe Systems Incorporated //
// All Rights Reserved. //
// //
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the //
// terms of the Adobe license agreement accompanying it. If you have received this file from a //
// source other than Adobe, then your use, modification, or distribution of it requires the prior //
// written permission of Adobe. //
/////////////////////////////////////////////////////////////////////////////////////////////////////-->
<!--/*
* Copyright 2017 FreshPlanet
* 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.
*/-->

<extension xmlns="http://ns.adobe.com/air/extension/20.0">

<extension xmlns="http://ns.adobe.com/air/extension/22.0">
<id>com.freshplanet.ane.AirNetworkInfo</id>
<versionNumber>1</versionNumber>
<platforms>
Expand Down
Empty file modified build/extractJars.sh 100755 → 100644
Empty file.
20 changes: 20 additions & 0 deletions build/platform-android.xml
@@ -0,0 +1,20 @@
<!--/*
* Copyright 2017 FreshPlanet
* 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.
*/-->
<platform xmlns="http://ns.adobe.com/air/extension/22.0">
<packagedDependencies>
</packagedDependencies>
<packagedResources>
</packagedResources>
</platform>
38 changes: 17 additions & 21 deletions build/platform-ios.xml
@@ -1,24 +1,20 @@
<!--
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2012 Freshplanet (http://freshplanet.com | opensource@freshplanet.com)
//
// 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.
//
//////////////////////////////////////////////////////////////////////////////////////
-->
<platform xmlns="http://ns.adobe.com/air/extension/20.0">
<sdkVersion>7.0</sdkVersion>
<!--/*
* Copyright 2017 FreshPlanet
* 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.
*/-->

<platform xmlns="http://ns.adobe.com/air/extension/22.0">
<sdkVersion>9.0</sdkVersion>
<linkerOptions>
<option>-framework Foundation</option>
<option>-framework CoreTelephony</option>
Expand Down
4 changes: 2 additions & 2 deletions ios/AirNetworkInfo.xcodeproj/project.pbxproj
Expand Up @@ -244,7 +244,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -286,7 +286,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand Down
133 changes: 3 additions & 130 deletions ios/AirNetworkInfo/AirNetworkInfo.m
Expand Up @@ -84,133 +84,6 @@ - (int)getConnectivityStatus {

@end

//FREObject getInterfaceProperties(struct ifaddrs* ifa, FREObject NetworkInterfaceArray) {
//
// void* tmpAddrPtr = NULL;
// void* tmpbroadPtr = NULL;
// char* iPVersion = "IPV4";
// int PrefixLength = -1;
//
// FREObject InterfaceAddrsArray[4];
//
// FREObject Addrstemp = nil;
// BOOL state = FALSE;
//
// if (ifa->ifa_addr->sa_family == AF_INET) {
//
// // If the address is a valid IP4 Address, get its properties and put them into the InterfaceAddrsArray.
//
// tmpAddrPtr = &((struct sockaddr_in*) ifa->ifa_addr)->sin_addr;
// char addressBuffer[INET_ADDRSTRLEN];
// inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
// tmpbroadPtr = &((struct sockaddr_in*) ifa->ifa_broadaddr)->sin_addr;
//
// //
// // I haven't found any clear way to determine if the interface is active.
// // The issue is that the IFM_ACTIVE flag indicates whether the interface is up and running,
// // but the IFM_ACTIVE flag does not exist on iOS.
// //
// // Furthermore, the IFF_UP and IFF_RUNNING flags are not sufficient to determine the state of interface.
// // These flags fail to indicate the correct status when the WIFI is down.
//
// // Therefore, the following code determines the availability of the cellular network and Wifi.
// // Only this information is used to determine whether the interface is active.
// // Note: The code assumes that the Wifi address is represented by "en0"
// // and the cellular network is represented by "pdp_xxx".
//
// // Create a zero address socket to determine if a connection is available.
// // If a connection is available, then either the Wifi or Cellular network or both are active.
// // Other flags are used to find out which network is active.
//
// struct sockaddr_in zeroAddress;
// bzero(&zeroAddress, sizeof(zeroAddress));
// zeroAddress.sin_len = sizeof(zeroAddress);
// zeroAddress.sin_family = AF_INET;
// SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr*) &zeroAddress);
// SCNetworkReachabilityFlags flags;
//
// BOOL didRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags);
// CFRelease(defaultRouteReachability);
//
// if (!didRetrieveFlags)
// return NULL;
//
// BOOL isReachable = flags & kSCNetworkFlagsReachable;
// BOOL needsConnection = flags & kSCNetworkFlagsConnectionRequired;
// BOOL status = (isReachable && !needsConnection) ? YES : NO;
//
// if (status) {
//
// if (strcmp(ifa->ifa_name, "en0") == 0) {
//
// if (!(flags & kSCNetworkReachabilityFlagsIsWWAN)) {
//
// state = TRUE;
// FRENewObjectFromBool(state, &NetworkInterfaceArray[3]);
// }
// } else {
//
// char* InterfaceStringPtr = ifa->ifa_name;
// NSString* string1 = [NSString stringWithCString:InterfaceStringPtr encoding:NSUTF8StringEncoding];
//
// if ([string1 rangeOfString:@"pdp"].location != NSNotFound) {
//
// if ((flags & kSCNetworkReachabilityFlagsIsWWAN)) {
//
// state = TRUE;
// FRENewObjectFromBool(state, &NetworkInterfaceArray[3]);
// }
// }
// }
// }
//
// char broadCastAddressBuffer[INET_ADDRSTRLEN];
// inet_ntop(AF_INET, tmpbroadPtr, broadCastAddressBuffer, INET_ADDRSTRLEN);
//
// // Create a new ActionScript object for the IP address, and put it in InterfaceAddrsArray.
// FRENewObjectFromUTF8(INET_ADDRSTRLEN, (const uint8_t*) addressBuffer, &InterfaceAddrsArray[0]);
//
// // Create a new ActionScript object for the broadcast address, and put it in InterfaceAddrsArray.
// FRENewObjectFromUTF8(INET_ADDRSTRLEN, (const uint8_t*) broadCastAddressBuffer, &InterfaceAddrsArray[1]);
//
// // Create a new ActionScript object for the prefix length, and put it in InterfaceAddrsArray.
// // Note: The PrefixLength is not currently supported. It has the value -1.
// FRENewObjectFromInt32(PrefixLength, &InterfaceAddrsArray[2]);
//
// // Create a new ActionScript object for the ip version, and put it in InterfaceAddrsArray.
// iPVersion = "IPV4";
// FRENewObjectFromUTF8(32, (const uint8_t*) iPVersion, &InterfaceAddrsArray[3]);
// } else if (ifa->ifa_addr->sa_family == AF_INET6) {
//
// // else if the address is a valid IP6 Address, get its properties and put them into the InterfaceAddrsArray.
// tmpAddrPtr = &((struct sockaddr_in*) ifa->ifa_addr)->sin_addr;
// char addressBuffer[INET6_ADDRSTRLEN];
// inet_ntop(AF_INET6, tmpAddrPtr, addressBuffer, INET6_ADDRSTRLEN);
//
// char* broadCastForIpv6 = "";
// // A broadcast address is not applicable in IPV6
//
// // Create a new ActionScript object for the IP address, and put it in InterfaceAddrsArray.
// FRENewObjectFromUTF8(INET6_ADDRSTRLEN, (const uint8_t*) addressBuffer, &InterfaceAddrsArray[0]);
//
// // Create a new ActionScript object for the broadcast address, and put it in InterfaceAddrsArray.
// FRENewObjectFromUTF8(INET_ADDRSTRLEN, (const uint8_t*) broadCastForIpv6, &InterfaceAddrsArray[1]);
//
// // Create a new ActionScript object for the prefix length, and put it in InterfaceAddrsArray.
// // Note: The PrefixLength is not currently supported. It has the value -1.
// FRENewObjectFromInt32(PrefixLength, &InterfaceAddrsArray[2]);
//
// // Create a new ActionScript object for the ip version, and put it in InterfaceAddrsArray.
// iPVersion = "IPV6";
// FRENewObjectFromUTF8(32, (const uint8_t*) iPVersion, &InterfaceAddrsArray[3]);
// }
//
// // Create an ActionScript InterfaceAddress object. InterfaceAddrsArray contains the parameters to the constructor.
// // Addrstemp is the corresponding FREObject for the new ActionScript object.
// FRENewObject((const uint8_t*) "com.freshplanet.nativeExtensions.InterfaceAddress", 4, InterfaceAddrsArray, &Addrstemp, nil);
//
// return Addrstemp;
//}

DEFINE_ANE_FUNCTION(getInterfaces) {

Expand Down Expand Up @@ -383,10 +256,10 @@ - (int)getConnectivityStatus {
NetworkInfoiOSLibrary* networkLib = (__bridge NetworkInfoiOSLibrary*) controller;

if (!controller)
return FPANE_CreateError(@"context's NetworkInfoiOSLibrary is null", 0);
return AirNetworkInfo_FPANE_CreateError(@"context's NetworkInfoiOSLibrary is null", 0);

int netStatus = [networkLib getConnectivityStatus];
FREObject freObj = FPANE_IntToFREObject(netStatus);
FREObject freObj = AirNetworkInfo_FPANE_IntToFREObject(netStatus);

return freObj;
}
Expand All @@ -399,7 +272,7 @@ - (int)getConnectivityStatus {

NSString *carrierName = [carrier carrierName];

return FPANE_NSStringToFREObject(carrierName);
return AirNetworkInfo_FPANE_NSStringToFREObject(carrierName);
}

void AirNetworkInfoContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, uint32_t* numFunctionsToSet, const FRENamedFunction** functionsToSet) {
Expand Down
28 changes: 14 additions & 14 deletions ios/FPANEUtils.h
Expand Up @@ -19,19 +19,19 @@
#define MAP_FUNCTION(fn, data) { (const uint8_t*)(#fn), (data), &(fn) }
#define ROOT_VIEW_CONTROLLER [[[UIApplication sharedApplication] keyWindow] rootViewController]

void FPANE_DispatchEvent(FREContext context, NSString* eventName);
void FPANE_DispatchEventWithInfo(FREContext context, NSString* eventName, NSString* eventInfo);
void FPANE_Log(FREContext context, NSString* message);
void AirNetworkInfo_FPANE_DispatchEvent(FREContext context, NSString* eventName);
void AirNetworkInfo_FPANE_DispatchEventWithInfo(FREContext context, NSString* eventName, NSString* eventInfo);
void AirNetworkInfo_FPANE_Log(FREContext context, NSString* message);

NSString* FPANE_FREObjectToNSString(FREObject object);
NSArray* FPANE_FREObjectToNSArrayOfNSString(FREObject object);
NSDictionary* FPANE_FREObjectsToNSDictionaryOfNSString(FREObject keys, FREObject values);
BOOL FPANE_FREObjectToBool(FREObject object);
NSInteger FPANE_FREObjectToInt(FREObject object);
double FPANE_FREObjectToDouble(FREObject object);
NSString* AirNetworkInfo_FPANE_FREObjectToNSString(FREObject object);
NSArray* AirNetworkInfo_FPANE_FREObjectToNSArrayOfNSString(FREObject object);
NSDictionary* AirNetworkInfo_FPANE_FREObjectsToNSDictionaryOfNSString(FREObject keys, FREObject values);
BOOL AirNetworkInfo_FPANE_FREObjectToBool(FREObject object);
NSInteger AirNetworkInfo_FPANE_FREObjectToInt(FREObject object);
double AirNetworkInfo_FPANE_FREObjectToDouble(FREObject object);

FREObject FPANE_BOOLToFREObject(BOOL boolean);
FREObject FPANE_IntToFREObject(NSInteger i);
FREObject FPANE_DoubleToFREObject(double d);
FREObject FPANE_NSStringToFREObject(NSString* string);
FREObject FPANE_CreateError(NSString* error, NSInteger* id);
FREObject AirNetworkInfo_FPANE_BOOLToFREObject(BOOL boolean);
FREObject AirNetworkInfo_FPANE_IntToFREObject(NSInteger i);
FREObject AirNetworkInfo_FPANE_DoubleToFREObject(double d);
FREObject AirNetworkInfo_FPANE_NSStringToFREObject(NSString* string);
FREObject AirNetworkInfo_FPANE_CreateError(NSString* error, NSInteger* id);

0 comments on commit 5e94e07

Please sign in to comment.