diff --git a/Classes/LinphoneUI/LinphoneManager.h b/Classes/LinphoneUI/LinphoneManager.h index 547621f07..d817f5964 100644 --- a/Classes/LinphoneUI/LinphoneManager.h +++ b/Classes/LinphoneUI/LinphoneManager.h @@ -22,6 +22,11 @@ #include "linphonecore.h" #import "LogView.h" #import "LinphoneUIDelegates.h" +typedef enum _Connectivity { + wifi, + wwan + ,none +} Connectivity; @interface LinphoneManager : NSObject { @private @@ -35,6 +40,7 @@ id registrationDelegate; UIViewController* mCurrentViewController; + Connectivity connectivity; } +(LinphoneManager*) instance; @@ -51,4 +57,5 @@ @property (nonatomic, retain) id callDelegate; @property (nonatomic, retain) id registrationDelegate; +@property Connectivity connectivity; @end diff --git a/Classes/LinphoneUI/LinphoneManager.m b/Classes/LinphoneUI/LinphoneManager.m index 188ce8d9c..f97158161 100644 --- a/Classes/LinphoneUI/LinphoneManager.m +++ b/Classes/LinphoneUI/LinphoneManager.m @@ -35,6 +35,7 @@ extern void libmsilbc_init(); @implementation LinphoneManager @synthesize callDelegate; @synthesize registrationDelegate; +@synthesize connectivity; +(LinphoneManager*) instance { if (theLinphoneManager==nil) { @@ -203,7 +204,9 @@ static void linphone_iphone_call_state(LinphoneCore *lc, LinphoneCall* call, Lin onDomain:lDomain forReason:lErrorMessage]; - if (lErrorMessage != nil && registrationDelegate==nil) { + if (lErrorMessage != nil + && registrationDelegate==nil + && linphone_proxy_config_get_error(cfg) != LinphoneReasonNoResponse) { //do not report network connection issue on registration //default behavior if no registration delegates UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Registration failure" @@ -259,21 +262,27 @@ static LinphoneCoreVTable linphonec_vtable = { void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void * info) { ms_message("Network connection flag [%x]",flags); + LinphoneManager* lLinphoneMgr = (LinphoneManager*)info; if ([LinphoneManager getLc] != nil) { if ((flags == 0) | (flags & (kSCNetworkReachabilityFlagsConnectionRequired |kSCNetworkReachabilityFlagsConnectionOnTraffic))) { [[LinphoneManager instance] kickOffNetworkConnection]; linphone_core_set_network_reachable([LinphoneManager getLc],false); + ((LinphoneManager*)info).connectivity = none; } else { - linphone_core_set_network_reachable([LinphoneManager getLc],true); + Connectivity newConnectivity = flags & kSCNetworkReachabilityFlagsIsWWAN ? wwan:wifi; + if (lLinphoneMgr.connectivity == none) { + linphone_core_set_network_reachable([LinphoneManager getLc],true); + } else if (lLinphoneMgr.connectivity != newConnectivity) { + // connectivity has changed + linphone_core_set_network_reachable([LinphoneManager getLc],false); + linphone_core_set_network_reachable([LinphoneManager getLc],true); + } + lLinphoneMgr.connectivity=newConnectivity; + ms_message("new network connectivity of type [%s]",(newConnectivity==wifi?"wifi":"wwan")); } } } --(void) doRegister { - SCNetworkReachabilityFlags reachabilityFlags; - SCNetworkReachabilityGetFlags (proxyReachability,&reachabilityFlags); - networkReachabilityCallBack(proxyReachability,reachabilityFlags,self); -} -(void) doLinphoneConfiguration:(NSNotification *)notification { ms_message("Configuring Linphone"); @@ -290,8 +299,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach } NSString* transport = [[NSUserDefaults standardUserDefaults] stringForKey:@"transport_preference"]; - //initial state is network off should be done as soon as possible - linphone_core_set_network_reachable(theLinphoneCore,false); + LCSipTransports transportValue; if (transport!=nil) { @@ -392,9 +400,6 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach LinphoneAddress* addr=linphone_address_new(linphone_proxy_config_get_addr(proxyCfg)); proxyReachability=SCNetworkReachabilityCreateWithName(nil, linphone_address_get_domain(addr)); - - - [self doRegister]; } else { if (configCheckDisable == false && (!domain && !username)) { @@ -472,9 +477,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach if (isbackgroundModeEnabled && proxyCfg) { //For registration register - linphone_core_set_network_reachable(theLinphoneCore,false); - linphone_core_iterate(theLinphoneCore); - linphone_core_set_network_reachable(theLinphoneCore,true); + linphone_core_refresh_registers(theLinphoneCore); //wait for registration answer @@ -492,10 +495,8 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach return; } //kick up network cnx, just in case - linphone_core_set_network_reachable(theLinphoneCore,false); - linphone_core_iterate(theLinphoneCore); [self kickOffNetworkConnection]; - linphone_core_set_network_reachable(theLinphoneCore,true); + linphone_core_refresh_registers(theLinphoneCore); linphone_core_iterate(theLinphoneCore); } ]) { @@ -571,7 +572,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach NSString* factoryConfig = [myBundle pathForResource:@"linphonerc"ofType:nil] ; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *confiFileName = [[paths objectAtIndex:0] stringByAppendingString:@"/.linphonerc"]; - ; + connectivity=none; signal(SIGPIPE, SIG_IGN); //log management @@ -600,7 +601,8 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach selector:@selector(doLinphoneConfiguration:) name:NSUserDefaultsDidChangeNotification object:nil]; - + //initial state is network off should be done as soon as possible + linphone_core_set_network_reachable(theLinphoneCore,false); // start scheduler mIterateTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self @@ -632,7 +634,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach } else { ms_message("becomming active, make sure we are registered"); linphone_core_start_dtmf_stream(theLinphoneCore); - [self doRegister]; + linphone_core_refresh_registers(theLinphoneCore);//just to make sure REGISTRATION is up to date } diff --git a/linphone-Info.plist b/linphone-Info.plist index f67e120c5..6fe6b4ae7 100644 --- a/linphone-Info.plist +++ b/linphone-Info.plist @@ -21,11 +21,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 3.3.4 + 3.3.4.2 CFBundleSignature ???? CFBundleVersion - 1.0.3 + 1.0.3.2 NSMainNibFile PhoneMainView UIBackgroundModes diff --git a/submodules/linphone b/submodules/linphone index 7818dee64..2d8af395d 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 7818dee64bbdcb448d213d1bada84072488d4d4e +Subproject commit 2d8af395db72bfe7737b2f9f9a5e98d453469b3e