diff --git a/Classes/Base.lproj/WizardViews.xib b/Classes/Base.lproj/WizardViews.xib
index 9dfd810ea..dfaa56be8 100644
--- a/Classes/Base.lproj/WizardViews.xib
+++ b/Classes/Base.lproj/WizardViews.xib
@@ -1,7 +1,7 @@
-
+
-
+
@@ -14,6 +14,7 @@
+
@@ -291,13 +292,6 @@
-
@@ -316,7 +310,7 @@
@@ -455,4 +443,4 @@
-
\ No newline at end of file
+
diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m
index 6a91d6492..ceac72039 100644
--- a/Classes/LinphoneCoreSettingsStore.m
+++ b/Classes/LinphoneCoreSettingsStore.m
@@ -76,6 +76,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
LinphoneCore *lc=[LinphoneManager getLc];
LinphoneProxyConfig *cfg=NULL;
linphone_core_get_default_proxy(lc,&cfg);
+ LinphoneTransportType transport = LinphoneTransportUdp;
if (cfg){
const char *identity=linphone_proxy_config_get_identity(cfg);
LinphoneAddress *addr=linphone_address_new(identity);
@@ -83,6 +84,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
const char *proxy=linphone_proxy_config_get_addr(cfg);
LinphoneAddress *proxy_addr=linphone_address_new(proxy);
int port=linphone_address_get_port(proxy_addr);
+ transport = linphone_address_get_transport(proxy_addr);
[self setString: linphone_address_get_username(addr) forKey:@"username_preference"];
[self setString: linphone_address_get_domain(addr) forKey:@"domain_preference"];
@@ -96,12 +98,13 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
}else snprintf(tmp,sizeof(tmp)-1,"%s",linphone_address_get_domain(proxy_addr));
[self setString: tmp forKey:@"proxy_preference"];
}
- linphone_address_destroy(addr);
+
+ linphone_address_destroy(addr);
linphone_address_destroy(proxy_addr);
[self setBool: (linphone_proxy_config_get_route(cfg)!=NULL) forKey:@"outbound_proxy_preference"];
[self setBool:linphone_proxy_config_get_dial_escape_plus(cfg) forKey:@"substitute_+_by_00_preference"];
-
+
}
} else {
[self setInteger: lp_config_get_int(linphone_core_get_config(lc),"default_values","reg_expires", 600) forKey:@"expire_preference"];
@@ -111,8 +114,27 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
[self setObject:@"" forKey:@"password_preference"];
[self setBool:FALSE forKey:@"outbound_proxy_preference"];
}
-
- [self setBool:lp_config_get_int(linphone_core_get_config(lc), LINPHONERC_APPLICATION_KEY, "pushnotification_preference", 0) forKey:@"pushnotification_preference"];
+ {
+ LCSipTransports tp;
+ linphone_core_get_sip_transports(lc, &tp);
+ const char *tname = "udp";
+ int port = 5060;
+ switch( transport ){
+ case LinphoneTransportUdp:
+ case LinphoneTransportDtls: tname = "udp"; port = tp.udp_port; break;
+ case LinphoneTransportTcp: tname = "tcp"; port = tp.tcp_port;break;
+ case LinphoneTransportTls: tname = "tls"; port = tp.tls_port;break;
+ }
+
+ [self setString:tname forKey:@"transport_preference"];
+ [self setInteger:port forKey:@"port_preference"];
+
+ [self setInteger:lp_config_get_int(linphone_core_get_config(lc),LINPHONERC_APPLICATION_KEY,"random_port_preference", 1) forKey:@"random_port_preference"];
+ }
+
+
+ BOOL push_notif = lp_config_get_int(linphone_core_get_config(lc), LINPHONERC_APPLICATION_KEY, "pushnotification_preference", 0);
+ [self setBool:push_notif forKey:@"pushnotification_preference"];
{
LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed(lc);
if(parsed != NULL) {
@@ -147,31 +169,13 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
[self setFloat:linphone_core_get_playback_gain_db(lc) forKey:@"playback_gain_preference"];
[self setFloat:linphone_core_get_mic_gain_db(lc) forKey:@"microphone_gain_preference"];
}
- {
- LCSipTransports tp;
- const char *tname = "udp";
- int port = 5060;
- linphone_core_get_sip_transports(lc, &tp);
- if (tp.udp_port>0) {
- tname = "udp";
- port = tp.udp_port;
- } else if (tp.tcp_port>0) {
- tname = "tcp";
- port = tp.tcp_port;
- } else if (tp.tls_port>0) {
- tname = "tls";
- port = tp.tls_port;
- }
- [self setString:tname forKey:@"transport_preference"];
- [self setInteger:port forKey:@"port_preference"];
-
- [self setInteger:lp_config_get_int(linphone_core_get_config(lc),"sip","sip_random_port", 1) forKey:@"random_port_preference"];
- }
+
{
LinphoneAuthInfo *ai;
const MSList *elem=linphone_core_get_auth_info_list(lc);
if (elem && (ai=(LinphoneAuthInfo*)elem->data)){
[self setString: linphone_auth_info_get_passwd(ai) forKey:@"password_preference"];
+ [self setString: linphone_auth_info_get_ha1(ai) forKey:@"password_ha1_preference"];
}
}
{
@@ -291,6 +295,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
- (void)synchronizeAccount {
LinphoneCore *lc = [LinphoneManager getLc];
+ LpConfig* conf = linphone_core_get_config(lc);
LinphoneManager* lLinphoneMgr = [LinphoneManager instance];
LinphoneProxyConfig* proxyCfg = NULL;
/* unregister before modifying any settings */
@@ -312,43 +317,43 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
}
}
- NSString* transport = [self stringForKey:@"transport_preference"];
- int port_preference = [self integerForKey:@"port_preference"];
-
+ NSString* transport = [self stringForKey:@"transport_preference"];
+ int port_preference = [self integerForKey:@"port_preference"];
BOOL random_port_preference = [self boolForKey:@"random_port_preference"];
- lp_config_set_int(linphone_core_get_config(lc),"sip","sip_random_port", random_port_preference);
- lp_config_set_int(linphone_core_get_config(lc),"sip","sip_tcp_random_port", random_port_preference);
- lp_config_set_int(linphone_core_get_config(lc),"sip","sip_tls_random_port", random_port_preference);
+ LCSipTransports transportValue = {0};
+ LinphoneTransportType transportType = LinphoneTransportUdp;
+
+ // re-generate the random port if necessary
if(random_port_preference) {
port_preference = (0xDFFF&random())+1024;
[self setInteger:port_preference forKey:@"port_preference"]; // Update back preference
}
-
- LCSipTransports transportValue={0};
- if (transport!=nil) {
- if (linphone_core_get_sip_transports(lc, &transportValue)) {
- [LinphoneLogger logc:LinphoneLoggerError format:"cannot get current transport"];
- }
- // Only one port can be set at one time, the others's value is 0
- if ([transport isEqualToString:@"tcp"]) {
- transportValue.tcp_port=port_preference;
- transportValue.udp_port=0;
- transportValue.tls_port=0;
- } else if ([transport isEqualToString:@"udp"]){
- transportValue.udp_port=port_preference;
- transportValue.tcp_port=0;
- transportValue.tls_port=0;
- } else if ([transport isEqualToString:@"tls"]){
- transportValue.tls_port=port_preference;
- transportValue.tcp_port=0;
- transportValue.udp_port=0;
- } else {
- [LinphoneLogger logc:LinphoneLoggerError format:"unexpected transport [%s]",[transport cStringUsingEncoding:[NSString defaultCStringEncoding]]];
- }
- if (linphone_core_set_sip_transports(lc, &transportValue)) {
- [LinphoneLogger logc:LinphoneLoggerError format:"cannot set transport"];
- }
- }
+
+ // reset ports
+ lp_config_set_int(conf,"sip","sip_udp_port", 0);
+ lp_config_set_int(conf,"sip","sip_tcp_port", 0);
+ lp_config_set_int(conf,"sip","sip_tls_port", 0);
+
+ // only activate the selected transport
+ if( [transport isEqualToString:@"udp"] ){
+ lp_config_set_int(conf,"sip","sip_port", port_preference);
+ transportValue.udp_port = port_preference;
+ transportType = LinphoneTransportUdp;
+ } else if( [transport isEqualToString:@"tcp"] ) {
+ lp_config_set_int(conf,"sip","sip_tcp_port", port_preference);
+ transportValue.tcp_port = port_preference;
+ transportType = LinphoneTransportTcp;
+ } else if( [transport isEqualToString:@"tls"] ) {
+ lp_config_set_int(conf,"sip","sip_tls_port", port_preference);
+ transportValue.tls_port = port_preference;
+ transportType = LinphoneTransportTls;
+ }
+
+ lp_config_set_int(conf,LINPHONERC_APPLICATION_KEY,"random_port_preference", random_port_preference);
+
+ if (linphone_core_set_sip_transports(lc, &transportValue)) {
+ [LinphoneLogger logc:LinphoneLoggerError format:"cannot set transport"];
+ }
BOOL enable_ipv6 = [self boolForKey:@"use_ipv6"];
lp_config_set_int(linphone_core_get_config(lc), "sip", "use_ipv6", enable_ipv6);
@@ -364,6 +369,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
NSString* username = [self stringForKey:@"username_preference"];
NSString* domain = [self stringForKey:@"domain_preference"];
NSString* accountPassword = [self stringForKey:@"password_preference"];
+ NSString* sha1 = [self stringForKey:@"password_ha1_preference"];
bool isOutboundProxy= [self boolForKey:@"outbound_proxy_preference"];
@@ -372,43 +378,53 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
//clear existing proxy config
linphone_core_clear_proxy_config(lc);
if (username && [username length] >0 && domain && [domain length]>0) {
- NSString* proxyAddress = [self stringForKey:@"proxy_preference"];
- if ((!proxyAddress || [proxyAddress length] <1 ) && domain) {
- proxyAddress = [NSString stringWithFormat:@"sip:%@",domain] ;
+ NSString* proxy_pref = [self stringForKey:@"proxy_preference"];
+ if ((!proxy_pref || [proxy_pref length] <1 ) && domain) {
+ proxy_pref = [NSString stringWithFormat:@"sip:%@",domain] ;
} else {
- proxyAddress = [NSString stringWithFormat:@"sip:%@",proxyAddress] ;
+ proxy_pref = [NSString stringWithFormat:@"sip:%@",proxy_pref] ;
}
- const char* proxy = [proxyAddress cStringUsingEncoding:[NSString defaultCStringEncoding]];
-
-
-
//possible valid config detected
proxyCfg = linphone_core_create_proxy_config(lc);
- char normalizedUserName[256];
+
+ // prepare identity
+ char normalizedUserName[256];
LinphoneAddress* linphoneAddress = linphone_address_new("sip:user@domain.com");
- linphone_proxy_config_normalize_number(proxyCfg, [username cStringUsingEncoding:[NSString defaultCStringEncoding]], normalizedUserName, sizeof(normalizedUserName));
+ linphone_proxy_config_normalize_number(proxyCfg, [username cStringUsingEncoding:[NSString defaultCStringEncoding]],
+ normalizedUserName, sizeof(normalizedUserName));
linphone_address_set_username(linphoneAddress, normalizedUserName);
linphone_address_set_domain(linphoneAddress, [domain cStringUsingEncoding:[NSString defaultCStringEncoding]]);
- const char* identity = linphone_address_as_string_uri_only(linphoneAddress);
- const char* password = [accountPassword cStringUsingEncoding:[NSString defaultCStringEncoding]];
- // configure proxy entries
+ const char* identity = linphone_address_as_string_uri_only(linphoneAddress);
linphone_proxy_config_set_identity(proxyCfg, identity);
- linphone_proxy_config_set_server_addr(proxyCfg, proxy);
+
+ // proxy address
+ LinphoneAddress* proxyAddress = linphone_address_new([proxy_pref cStringUsingEncoding:[NSString defaultCStringEncoding]]);
+ const char* proxy = "";
+ if( proxyAddress ){
+ linphone_address_set_transport(proxyAddress, transportType);
+ proxy = linphone_address_as_string_uri_only(proxyAddress);
+ linphone_proxy_config_set_server_addr(proxyCfg, proxy);
+ }
+ if (isOutboundProxy)
+ linphone_proxy_config_set_route(proxyCfg, proxy);
+ if(proxyAddress) linphone_address_destroy(proxyAddress);
+
+
linphone_proxy_config_enable_register(proxyCfg, true);
// add username password
LinphoneAddress *from = linphone_address_new(identity);
+ const char* password = [accountPassword cStringUsingEncoding:[NSString defaultCStringEncoding]];
LinphoneAuthInfo *info;
if (from != 0){
- info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,NULL,NULL,linphone_proxy_config_get_domain(proxyCfg));
+ // only use ha1 if the password is NULL. This allows for remote provisioning to send the SHA1 without disclosing the password
+ const char* ha1 = password ? NULL : [sha1 cStringUsingEncoding:[NSString defaultCStringEncoding]];
+ info=linphone_auth_info_new(linphone_address_get_username(from), NULL, password, ha1, NULL, linphone_proxy_config_get_domain(proxyCfg));
linphone_core_add_auth_info(lc,info);
linphone_address_destroy(from);
}
-
-
-
int expire = [self integerForKey:@"expire_preference"];
linphone_proxy_config_expires(proxyCfg,expire);
@@ -421,10 +437,10 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
linphone_proxy_config_expires(proxyCfg, expire);
}
- if (isOutboundProxy)
- linphone_proxy_config_set_route(proxyCfg, proxy);
-
- if ([self objectForKey:@"prefix_preference"]) {
+
+
+
+ if ([self objectForKey:@"prefix_preference"]) {
NSString* prefix = [self stringForKey:@"prefix_preference"];
if ([prefix length]>0) {
linphone_proxy_config_set_dial_prefix(proxyCfg, [prefix cStringUsingEncoding:[NSString defaultCStringEncoding]]);
diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h
index feb65bb37..df20cbaf2 100644
--- a/Classes/LinphoneManager.h
+++ b/Classes/LinphoneManager.h
@@ -177,6 +177,7 @@ typedef struct _LinphoneManagerSounds {
@property (readonly) NSString* contactSipField;
@property (readonly,copy) NSString* contactFilter;
@property (copy) void (^silentPushCompletion)(UIBackgroundFetchResult);
+@property (readonly) BOOL wasRemoteProvisioned;
@end
diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m
index 9d14e929d..efe77cb31 100644
--- a/Classes/LinphoneManager.m
+++ b/Classes/LinphoneManager.m
@@ -112,6 +112,7 @@ extern void libmsbcg729_init();
@synthesize bluetoothEnabled;
@synthesize photoLibrary;
@synthesize silentPushCompletion;
+@synthesize wasRemoteProvisioned;
struct codec_name_pref_table{
const char *name;
@@ -288,6 +289,8 @@ struct codec_name_pref_table codec_pref_table[]={
}
[[NSNotificationCenter defaultCenter] removeObserver:self forKeyPath:kLinphoneGlobalStateUpdate];
+ [[NSNotificationCenter defaultCenter] removeObserver:self forKeyPath:kLinphoneConfiguringStateUpdate];
+
[photoLibrary release];
[pendindCallIdFromRemoteNotif release];
@@ -344,6 +347,31 @@ struct codec_name_pref_table codec_pref_table[]={
}
+struct _entry_data {
+ const LpConfig* conf;
+ const char* section;
+};
+
+static void dump_entry(const char* entry, void*data) {
+ struct _entry_data *d = (struct _entry_data*)data;
+ const char* value = lp_config_get_string(d->conf, d->section, entry, "");
+ [LinphoneLogger log:LinphoneLoggerLog format:@"%s=%s", entry, value];
+}
+
+static void dump_section(const char* section, void* data){
+ [LinphoneLogger log:LinphoneLoggerLog format:@"[%s]", section ];
+ struct _entry_data d = {(const LpConfig*)data, section};
+ lp_config_for_each_entry((const LpConfig*)data, section, dump_entry, &d);
+}
+
++ (void)dumpLCConfig {
+ if(theLinphoneCore ){
+ LpConfig* conf = linphone_core_get_config(theLinphoneCore);
+ lp_config_for_each_section(conf, dump_section, conf);
+ }
+}
+
+
#pragma mark - Logs Functions
//generic log handler for debug version
@@ -620,6 +648,16 @@ static void linphone_iphone_configuring_status_changed(LinphoneCore *lc, Linphon
});
}
+
+-(void)configuringStateChangedNotificationHandler:(NSNotification*)notif {
+ if( (LinphoneConfiguringState)[[[notif userInfo] valueForKey:@"state"] integerValue] == LinphoneConfiguringSuccessful){
+ wasRemoteProvisioned = TRUE;
+ } else {
+ wasRemoteProvisioned = FALSE;
+ }
+}
+
+
#pragma mark - Registration State Functions
- (void)onRegister:(LinphoneCore *)lc cfg:(LinphoneProxyConfig*) cfg state:(LinphoneRegistrationState) state message:(const char*) message {
@@ -900,7 +938,6 @@ static LinphoneCoreVTable linphonec_vtable = {
linphone_core_iterate(theLinphoneCore);
}
-
- (void)audioSessionInterrupted:(NSNotification *)notification
{
int interruptionType = [notification.userInfo[AVAudioSessionInterruptionTypeKey] intValue];
@@ -985,18 +1022,18 @@ static LinphoneCoreVTable linphonec_vtable = {
- (void)startLibLinphone {
- if (theLinphoneCore != nil) {
- [LinphoneLogger logc:LinphoneLoggerLog format:"linphonecore is already created"];
+
+ static BOOL libStarted = FALSE;
+ if ( libStarted ) {
+ [LinphoneLogger logc:LinphoneLoggerError format:"Liblinphone is already initialized!"];
return;
}
- NSString* factoryConfig = [LinphoneManager bundleFile:[LinphoneManager runningOnIpad]?@"linphonerc-factory~ipad":@"linphonerc-factory"];
- NSString *confiFileName = [LinphoneManager documentFile:@".linphonerc"];
-
+ libStarted = TRUE;
+
connectivity = none;
signal(SIGPIPE, SIG_IGN);
- //log management
-
+
libmsilbc_init();
#if defined (HAVE_SILK)
libmssilk_init();
@@ -1011,43 +1048,21 @@ static LinphoneCoreVTable linphonec_vtable = {
#if HAVE_G729
libmsbcg729_init(); // load g729 plugin
#endif
- /* Initialize linphone core*/
-
+
/*to make sure we don't loose debug trace*/
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"debugenable_preference"]) {
linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler);
ortp_set_log_level_mask(ORTP_DEBUG|ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
}
- [LinphoneLogger logc:LinphoneLoggerLog format:"Create linphonecore"];
- theLinphoneCore = linphone_core_new (&linphonec_vtable
- , [confiFileName cStringUsingEncoding:[NSString defaultCStringEncoding]]
- , [factoryConfig cStringUsingEncoding:[NSString defaultCStringEncoding]]
- ,self /* user_data */);
-
- /* The core will call the linphone_iphone_configuring_status_changed callback when the remote provisioning is loaded (or skipped).
- Wait for this to finish the code configuration */
-
- // start scheduler
- mIterateTimer = [NSTimer scheduledTimerWithTimeInterval:0.02
- target:self
- selector:@selector(iterate)
- userInfo:nil
- repeats:YES];
+ // create linphone core
+ [self createLinphoneCore];
//init audio session
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
BOOL bAudioInputAvailable= audioSession.inputAvailable;
NSError* err;
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(audioSessionInterrupted:)
- name:AVAudioSessionInterruptionNotification
- object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(globalStateChangedNotificationHandler:) name:kLinphoneGlobalStateUpdate object:nil];
-
-
-
if( ![audioSession setActive:NO error: &err] && err ){
NSLog(@"audioSession setActive failed: %@", [err description]);
}
@@ -1069,6 +1084,42 @@ static LinphoneCoreVTable linphonec_vtable = {
}
+- (void)createLinphoneCore {
+
+ if (theLinphoneCore != nil) {
+ [LinphoneLogger logc:LinphoneLoggerLog format:"linphonecore is already created"];
+ return;
+ }
+ [LinphoneLogger logc:LinphoneLoggerLog format:"Create linphonecore"];
+
+ connectivity=none;
+
+ NSString* factoryConfig = [LinphoneManager bundleFile:[LinphoneManager runningOnIpad]?@"linphonerc-factory~ipad":@"linphonerc-factory"];
+ NSString *confiFileName = [LinphoneManager documentFile:@".linphonerc"];
+ theLinphoneCore = linphone_core_new (&linphonec_vtable
+ , [confiFileName cStringUsingEncoding:[NSString defaultCStringEncoding]]
+ , [factoryConfig cStringUsingEncoding:[NSString defaultCStringEncoding]]
+ ,self /* user_data */);
+
+ /* set the CA file no matter what, since the remote provisioning could be hitting an HTTPS server */
+ const char* lRootCa = [[LinphoneManager bundleFile:@"rootca.pem"] cStringUsingEncoding:[NSString defaultCStringEncoding]];
+ linphone_core_set_root_ca(theLinphoneCore, lRootCa);
+
+ /* The core will call the linphone_iphone_configuring_status_changed callback when the remote provisioning is loaded (or skipped).
+ Wait for this to finish the code configuration */
+
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioSessionInterrupted:) name:AVAudioSessionInterruptionNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(globalStateChangedNotificationHandler:) name:kLinphoneGlobalStateUpdate object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(configuringStateChangedNotificationHandler:) name:kLinphoneConfiguringStateUpdate object:nil];
+
+ // start scheduler
+ mIterateTimer = [NSTimer scheduledTimerWithTimeInterval:0.02
+ target:self
+ selector:@selector(iterate)
+ userInfo:nil
+ repeats:YES];
+}
+
- (void)destroyLibLinphone {
[mIterateTimer invalidate];
//just in case
@@ -1095,35 +1146,10 @@ static LinphoneCoreVTable linphonec_vtable = {
- (void) resetLinphoneCore {
[self destroyLibLinphone];
- if (theLinphoneCore != nil) {
- [LinphoneLogger logc:LinphoneLoggerLog format:"linphonecore is already created"];
- return;
- }
- [LinphoneLogger logc:LinphoneLoggerLog format:"Create linphonecore"];
+ [self createLinphoneCore];
- NSString* factoryConfig = [LinphoneManager bundleFile:[LinphoneManager runningOnIpad]?@"linphonerc-factory~ipad":@"linphonerc-factory"];
- NSString *confiFileName = [LinphoneManager documentFile:@".linphonerc"];
- theLinphoneCore = linphone_core_new (&linphonec_vtable
- , [confiFileName cStringUsingEncoding:[NSString defaultCStringEncoding]]
- , [factoryConfig cStringUsingEncoding:[NSString defaultCStringEncoding]]
- ,self /* user_data */);
-
- /* The core will call the linphone_iphone_configuring_status_changed callback when the remote provisioning is loaded (or skipped).
- Wait for this to finish the code configuration */
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioSessionInterrupted:) name:AVAudioSessionInterruptionNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(globalStateChangedNotificationHandler:) name:kLinphoneGlobalStateUpdate object:nil];
- connectivity=none;
+ // reset network state to trigger a new network connectivity assessment
linphone_core_set_network_reachable(theLinphoneCore, FALSE);
- // start scheduler
- mIterateTimer = [NSTimer scheduledTimerWithTimeInterval:0.02
- target:self
- selector:@selector(iterate)
- userInfo:nil
- repeats:YES];
-
-
-
}
static int comp_call_id(const LinphoneCall* call , const char *callid) {
diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m
index 3b1f0e798..c19bf65e3 100644
--- a/Classes/PhoneMainView.m
+++ b/Classes/PhoneMainView.m
@@ -237,13 +237,16 @@ static PhoneMainView* phoneMainViewInstance=nil;
}
- (void)onGlobalStateChanged:(NSNotification*)notif {
- LinphoneConfiguringState state = [[[notif userInfo] valueForKey:@"state"] integerValue];
- LinphoneAppDelegate *appDelegate = (LinphoneAppDelegate *)[[UIApplication sharedApplication] delegate];
- if( state == LinphoneGlobalOn && !(appDelegate.started) ){
- if( [[LinphoneManager instance] lpConfigBoolForKey:@"show_login_view" forSection:@"app"] ){
+ LinphoneGlobalState state = [[[notif userInfo] valueForKey:@"state"] integerValue];
+ static BOOL already_shown = FALSE;
+ if( state == LinphoneGlobalOn && !already_shown && [LinphoneManager instance].wasRemoteProvisioned ){
+ LinphoneProxyConfig* conf = NULL;
+ linphone_core_get_default_proxy([LinphoneManager getLc], &conf);
+ if( [[LinphoneManager instance] lpConfigBoolForKey:@"show_login_view" forSection:@"app"] && conf == NULL){
+ already_shown = TRUE;
WizardViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[WizardViewController compositeViewDescription]], WizardViewController);
if(controller != nil) {
- [controller handleRemoteProvisioning];
+ [controller fillDefaultValues];
}
}
}
diff --git a/Classes/WizardViewController.h b/Classes/WizardViewController.h
index 32be00f2e..deea0c75e 100644
--- a/Classes/WizardViewController.h
+++ b/Classes/WizardViewController.h
@@ -51,6 +51,7 @@
@property (nonatomic, retain) IBOutlet UIButton *connectAccountButton;
@property (nonatomic, retain) IBOutlet UIButton *externalAccountButton;
@property (retain, nonatomic) IBOutlet UIButton *remoteProvisioningButton;
+@property (retain, nonatomic) IBOutlet UILabel *remoteParamsLabel;
@property (nonatomic, retain) IBOutlet UIImageView *choiceViewLogoImageView;
@@ -58,7 +59,7 @@
@property (nonatomic, retain) IBOutlet UITapGestureRecognizer *viewTapGestureRecognizer;
- (void)reset;
-- (void)handleRemoteProvisioning;
+- (void)fillDefaultValues;
- (IBAction)onStartClick:(id)sender;
- (IBAction)onBackClick:(id)sender;
diff --git a/Classes/WizardViewController.m b/Classes/WizardViewController.m
index 56df6e29e..cf60e7a72 100644
--- a/Classes/WizardViewController.m
+++ b/Classes/WizardViewController.m
@@ -56,6 +56,8 @@ typedef enum _ViewElement {
@synthesize createAccountButton;
@synthesize connectAccountButton;
@synthesize externalAccountButton;
+@synthesize remoteProvisioningButton;
+@synthesize remoteParamsLabel;
@synthesize choiceViewLogoImageView;
@@ -103,7 +105,8 @@ typedef enum _ViewElement {
[viewTapGestureRecognizer release];
- [_remoteProvisioningButton release];
+ [remoteProvisioningButton release];
+ [remoteParamsLabel release];
[super dealloc];
}
@@ -154,6 +157,7 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
+ [remoteParamsLabel setHidden:TRUE];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:kLinphoneRegistrationUpdate
object:nil];
@@ -200,25 +204,52 @@ static UICompositeViewDescription *compositeDescription = nil;
}
}
-- (void)handleRemoteProvisioning {
+- (void)fillDefaultValues {
+
+ LinphoneCore* lc = [LinphoneManager getLc];
[self resetTextFields];
+ LinphoneProxyConfig* current_conf = NULL;
+ linphone_core_get_default_proxy([LinphoneManager getLc], ¤t_conf);
+ if( current_conf != NULL ){
+ const char* proxy_addr = linphone_proxy_config_get_identity(current_conf);
+ if( proxy_addr ){
+ LinphoneAddress *addr = linphone_address_new( proxy_addr );
+ if( addr ){
+ const LinphoneAuthInfo *auth = linphone_core_find_auth_info(lc, NULL, linphone_address_get_username(addr), linphone_proxy_config_get_domain(current_conf));
+ linphone_address_destroy(addr);
+ if( auth ){
+ [LinphoneLogger log:LinphoneLoggerLog format:@"A proxy config was set up with the remote provisioning, skip wizard"];
+ [self onCancelClick:nil];
+ }
+ }
+ }
+ }
+
LinphoneProxyConfig* default_conf = linphone_core_create_proxy_config([LinphoneManager getLc]);
const char* identity = linphone_proxy_config_get_identity(default_conf);
if( identity ){
LinphoneAddress* default_addr = linphone_address_new(identity);
if( default_addr ){
const char* domain = linphone_address_get_domain(default_addr);
-
+ const char* username = linphone_address_get_username(default_addr);
if( domain && strlen(domain) > 0){
- UITextField* domainfield = [WizardViewController findTextField:ViewElement_Domain view:externalAccountView];
+ UITextField* domainfield = [WizardViewController findTextField:ViewElement_Domain view:externalAccountView];
[domainfield setText:[NSString stringWithUTF8String:domain]];
}
+
+ if( username && strlen(username) > 0 && username[0] != '?' ){
+ UITextField* userField = [WizardViewController findTextField:ViewElement_Username view:externalAccountView];
+ [userField setText:[NSString stringWithUTF8String:username]];
+ }
}
}
+
[self changeView:externalAccountView back:FALSE animation:TRUE];
+ [remoteParamsLabel setHidden:FALSE];
+
linphone_proxy_config_destroy(default_conf);
}
@@ -801,7 +832,7 @@ static UICompositeViewDescription *compositeDescription = nil;
switch (status) {
case LinphoneConfiguringSuccessful:
- [self handleRemoteProvisioning];
+ [self fillDefaultValues];
break;
case LinphoneConfiguringFailed:
{
@@ -1019,6 +1050,7 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewDidUnload {
[self setRemoteProvisioningButton:nil];
+ [self setRemoteParamsLabel:nil];
[super viewDidUnload];
}
@end
diff --git a/Classes/fr.lproj/WizardViews.strings b/Classes/fr.lproj/WizardViews.strings
index 9efc625df..c17690330 100644
--- a/Classes/fr.lproj/WizardViews.strings
+++ b/Classes/fr.lproj/WizardViews.strings
@@ -157,3 +157,18 @@
/* Class = "IBUIImageView"; accessibilityLabel = "Icône de l'assistant de configuration de compte"; ObjectID = "128"; */
"128.accessibilityLabel" = "Icône de l'assistant de configuration de compte";
+
+/* Class = "IBUIButton"; accessibilityLabel = "Sign in SIP account"; ObjectID = "Kbn-dL-C5h"; */
+"Kbn-dL-C5h.accessibilityLabel" = "Sign in SIP account";
+
+/* Class = "IBUIButton"; normalTitle = "Remote Provisioning"; ObjectID = "Kbn-dL-C5h"; */
+"Kbn-dL-C5h.normalTitle" = "Configuration distante";
+
+/* Class = "IBUILabel"; text = "remote provisioning details"; ObjectID = "W9Y-Z9-Rmz"; */
+"W9Y-Z9-Rmz.text" = "remote provisioning details";
+
+/* Class = "IBUILabel"; text = "Ces paramètres proviennent d'un fichier de provision récupéré ici:\n%@"; ObjectID = "bBb-47-pCq"; */
+"bBb-47-pCq.text" = "Ces paramètres proviennent d'un fichier de provision.";
+
+/* Class = "IBUILabel"; text = "Invalid character:"; ObjectID = "uHm-NE-GLV"; */
+"uHm-NE-GLV.text" = "Invalid character:";
diff --git a/Classes/ru.lproj/WizardViews.strings b/Classes/ru.lproj/WizardViews.strings
index 0f357de0c..a20825153 100644
--- a/Classes/ru.lproj/WizardViews.strings
+++ b/Classes/ru.lproj/WizardViews.strings
@@ -169,3 +169,18 @@
/* Class = "IBUIImageView"; accessibilityLabel = "Иконка помощника настройки"; ObjectID = "128"; */
"128.accessibilityLabel" = "Иконка помощника настройки";
+
+/* Class = "IBUIButton"; accessibilityLabel = "Sign in SIP account"; ObjectID = "Kbn-dL-C5h"; */
+"Kbn-dL-C5h.accessibilityLabel" = "Sign in SIP account";
+
+/* Class = "IBUIButton"; normalTitle = "Remote Provisioning"; ObjectID = "Kbn-dL-C5h"; */
+"Kbn-dL-C5h.normalTitle" = "Remote Provisioning";
+
+/* Class = "IBUILabel"; text = "remote provisioning details"; ObjectID = "W9Y-Z9-Rmz"; */
+"W9Y-Z9-Rmz.text" = "remote provisioning details";
+
+/* Class = "IBUILabel"; text = "These parameters were retrieve from the remote provisioning profile at this address:
%@"; ObjectID = "bBb-47-pCq"; */
+"bBb-47-pCq.text" = "These parameters were retrieve from the remote provisioning profile at this address:
%@";
+
+/* Class = "IBUILabel"; text = "Invalid character:"; ObjectID = "uHm-NE-GLV"; */
+"uHm-NE-GLV.text" = "Invalid character:";
diff --git a/Resources/linphonerc b/Resources/linphonerc
index ee656d368..be8cf3195 100644
--- a/Resources/linphonerc
+++ b/Resources/linphonerc
@@ -1,5 +1,4 @@
[sip]
-sip_random_port=1
contact="Linphone iPhone"
keepalive_period=30000
default_proxy=0
diff --git a/Resources/linphonerc-factory b/Resources/linphonerc-factory
index 8cc8260f8..f226a777a 100644
--- a/Resources/linphonerc-factory
+++ b/Resources/linphonerc-factory
@@ -13,6 +13,7 @@ register_only_when_network_is_up=1
auto_net_state_mon=0
keepalive_period=30000
ping_with_options=0
+sip_random_port=0
[rtp]
audio_jitt_comp=60
diff --git a/Resources/linphonerc-factory~ipad b/Resources/linphonerc-factory~ipad
index aa00ecfe4..5e4634154 100644
--- a/Resources/linphonerc-factory~ipad
+++ b/Resources/linphonerc-factory~ipad
@@ -13,6 +13,7 @@ register_only_when_network_is_up=1
auto_net_state_mon=0
keepalive_period=30000
ping_with_options=0
+sip_random_port=0
[rtp]
audio_jitt_comp=60
diff --git a/Resources/linphonerc~ipad b/Resources/linphonerc~ipad
index a0164663f..78405f5d4 100644
--- a/Resources/linphonerc~ipad
+++ b/Resources/linphonerc~ipad
@@ -1,5 +1,4 @@
[sip]
-sip_random_port=1
contact="Linphone iPhone"
keepalive_period=30000
default_proxy=0