mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
add tunnel auto mode
This commit is contained in:
parent
61f123df9b
commit
464c8e9535
4 changed files with 83 additions and 22 deletions
|
|
@ -27,6 +27,13 @@ typedef enum _Connectivity {
|
|||
wwan
|
||||
,none
|
||||
} Connectivity;
|
||||
typedef enum _TunnelMode {
|
||||
off
|
||||
,on
|
||||
,wwan_only
|
||||
,autodetect
|
||||
} TunnelMode;
|
||||
|
||||
@class FastAddressBook;
|
||||
@interface LinphoneManager : NSObject {
|
||||
@private
|
||||
|
|
@ -42,6 +49,7 @@ typedef enum _Connectivity {
|
|||
UIViewController* mCurrentViewController;
|
||||
Connectivity connectivity;
|
||||
FastAddressBook* mFastAddressBook;
|
||||
TunnelMode tunnelMode;
|
||||
|
||||
}
|
||||
+(LinphoneManager*) instance;
|
||||
|
|
@ -60,6 +68,7 @@ typedef enum _Connectivity {
|
|||
@property (nonatomic, retain) id<LinphoneUICallDelegate> callDelegate;
|
||||
@property (nonatomic, retain) id<LinphoneUIRegistrationDelegate> registrationDelegate;
|
||||
@property Connectivity connectivity;
|
||||
@property TunnelMode tunnelMode;
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -44,10 +44,12 @@ extern void libmsamr_init();
|
|||
@synthesize callDelegate;
|
||||
@synthesize registrationDelegate;
|
||||
@synthesize connectivity;
|
||||
@synthesize tunnelMode;
|
||||
|
||||
-(id) init {
|
||||
if ((self= [super init])) {
|
||||
mFastAddressBook = [[FastAddressBook alloc] init];
|
||||
tunnelMode = off;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
@ -339,6 +341,18 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
|
|||
linphone_core_set_network_reachable([LinphoneManager getLc],true);
|
||||
}
|
||||
lLinphoneMgr.connectivity=newConnectivity;
|
||||
switch (lLinphoneMgr.tunnelMode) {
|
||||
case wwan_only:
|
||||
sTunnelMgr->enable(lLinphoneMgr.connectivity == wwan);
|
||||
break;
|
||||
case autodetect:
|
||||
sTunnelMgr->autoDetect();
|
||||
break;
|
||||
default:
|
||||
//nothing to do
|
||||
break;
|
||||
}
|
||||
|
||||
ms_message("new network connectivity of type [%s]",(newConnectivity==wifi?"wifi":"wwan"));
|
||||
}
|
||||
|
||||
|
|
@ -468,7 +482,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
|
|||
}
|
||||
}
|
||||
//tunnel
|
||||
BOOL lTunnelPrefEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"tunnel_enabled_preference"];
|
||||
NSString* lTunnelPrefEnabled = [[NSUserDefaults standardUserDefaults] stringForKey:@"tunnel_enabled_preference"];
|
||||
NSString* lTunnelPrefAddress = [[NSUserDefaults standardUserDefaults] stringForKey:@"tunnel_address_preference"];
|
||||
NSString* lTunnelPrefPort = [[NSUserDefaults standardUserDefaults] stringForKey:@"tunnel_port_preference"];
|
||||
int lTunnelPort = 443;
|
||||
|
|
@ -477,9 +491,36 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
|
|||
}
|
||||
if (lTunnelPrefAddress && [lTunnelPrefAddress length]) {
|
||||
sTunnelMgr->cleanServers();
|
||||
sTunnelMgr->addServer([lTunnelPrefAddress cStringUsingEncoding:[NSString defaultCStringEncoding]],lTunnelPort);
|
||||
sTunnelMgr->addServer([lTunnelPrefAddress cStringUsingEncoding:[NSString defaultCStringEncoding]],lTunnelPort,12345/*default port*/,1000);
|
||||
}
|
||||
if ([lTunnelPrefEnabled isEqualToString:@"off"]) {
|
||||
tunnelMode=off;
|
||||
} else if ([lTunnelPrefEnabled isEqualToString:@"on"]) {
|
||||
tunnelMode=on;
|
||||
}else if ([lTunnelPrefEnabled isEqualToString:@"wwan"]) {
|
||||
tunnelMode=wwan_only;
|
||||
}else if ([lTunnelPrefEnabled isEqualToString:@"auto"]) {
|
||||
tunnelMode=autodetect;
|
||||
} else {
|
||||
ms_error("Unexpected tunnel mode [%s]",[lTunnelPrefEnabled cStringUsingEncoding:[NSString defaultCStringEncoding]]);
|
||||
}
|
||||
switch (tunnelMode) {
|
||||
case off:
|
||||
sTunnelMgr->enable(false);
|
||||
break;
|
||||
case on:
|
||||
sTunnelMgr->enable(true);
|
||||
break;
|
||||
case wwan_only:
|
||||
if (connectivity != wwan) {
|
||||
sTunnelMgr->enable(false);
|
||||
}
|
||||
break;
|
||||
case autodetect:
|
||||
sTunnelMgr->autoDetect();
|
||||
break;
|
||||
|
||||
}
|
||||
sTunnelMgr->enable(lTunnelPrefEnabled);
|
||||
|
||||
|
||||
//Configure Codecs
|
||||
|
|
@ -763,5 +804,4 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
|
|||
-(void) registerLogView:(id<LogView>) view {
|
||||
mLogView = view;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -161,38 +161,50 @@
|
|||
<dict>
|
||||
<key>Title</key>
|
||||
<string>Tunnel</string>
|
||||
<key>Type</key>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSTextFieldSpecifier</string>
|
||||
<key>Title</key>
|
||||
<string>Address</string>
|
||||
<key>Key</key>
|
||||
<string>tunnel_address_preference</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Title</key>
|
||||
<string>Address</string>
|
||||
<key>Type</key>
|
||||
<string>PSTextFieldSpecifier</string>
|
||||
<key>Title</key>
|
||||
<string>port</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Key</key>
|
||||
<string>tunnel_port_preference</string>
|
||||
<key>Title</key>
|
||||
<string>port</string>
|
||||
<key>Type</key>
|
||||
<string>PSTextFieldSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSToggleSwitchSpecifier</string>
|
||||
<key>Title</key>
|
||||
<string>Enable</string>
|
||||
<key>DefaultValue</key>
|
||||
<string>off</string>
|
||||
<key>Titles</key>
|
||||
<array>
|
||||
<string>off</string>
|
||||
<string>on</string>
|
||||
<string>wwan</string>
|
||||
<string>auto</string>
|
||||
</array>
|
||||
<key>Key</key>
|
||||
<string>tunnel_enabled_preference</string>
|
||||
<key>DefaultValue</key>
|
||||
<false/>
|
||||
<key>Title</key>
|
||||
<string>Enable</string>
|
||||
<key>Type</key>
|
||||
<string>PSMultiValueSpecifier</string>
|
||||
<key>Values</key>
|
||||
<array>
|
||||
<string>off</string>
|
||||
<string>on</string>
|
||||
<string>wwan</string>
|
||||
<string>auto</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
<key>Title</key>
|
||||
<string>Advanced</string>
|
||||
<key>Type</key>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 37968787d92eb67457b9e5e9197451b9b0765461
|
||||
Subproject commit 5890673a1ea3a5e3606a9b2fa472857807b8b6ce
|
||||
Loading…
Add table
Reference in a new issue