diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 51cb4a8ff..41bb737b9 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -43,17 +43,17 @@ [[LinphoneManager instance] becomeActive]; } -- (void)registerDefaultsFromSettingsBundle { - // source: http://stackoverflow.com/questions/510216/ +- (void) loadDefaultSettings { + NSString *settingsBundle = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"]; if(!settingsBundle) { NSLog(@"Could not find Settings.bundle"); return; } - + NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[settingsBundle stringByAppendingPathComponent:@"Root.plist"]]; NSArray *preferences = [settings objectForKey:@"PreferenceSpecifiers"]; - + NSMutableDictionary *defaultsToRegister = [[NSMutableDictionary alloc] initWithCapacity:[preferences count]]; for(NSDictionary *prefSpecification in preferences) { NSString *key = [prefSpecification objectForKey:@"Key"]; @@ -61,26 +61,15 @@ [defaultsToRegister setObject:[prefSpecification objectForKey:@"DefaultValue"] forKey:key]; } } - + + NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys: + @"NO", @"enable_first_login_view_preference", // + nil]; + + [defaultsToRegister addEntriesFromDictionary:appDefaults]; [[NSUserDefaults standardUserDefaults] registerDefaults:defaultsToRegister]; [defaultsToRegister release]; -} - -- (void) loadDefaultSettings { - - // if this is the first launch after installing, we would like to load default settings values from Settings.bundle - NSObject *somePrefVal = [[NSUserDefaults standardUserDefaults] objectForKey:@"debugenable_preference"]; - if(!somePrefVal) { - // has no value, so defaults have not been loaded yet - [self registerDefaultsFromSettingsBundle]; - } - - NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys: - @"NO", @"enable_first_login_view_preference", // - nil]; - - [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; - [[NSUserDefaults standardUserDefaults] synchronize]; + [[NSUserDefaults standardUserDefaults] synchronize]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ diff --git a/Classes/LinphoneUI/LinphoneManager.m b/Classes/LinphoneUI/LinphoneManager.m index b0d854c8f..5789f45d1 100644 --- a/Classes/LinphoneUI/LinphoneManager.m +++ b/Classes/LinphoneUI/LinphoneManager.m @@ -393,8 +393,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach proxyReachability=SCNetworkReachabilityCreateWithName(nil, linphone_address_get_domain(addr)); } else { - if (configCheckDisable == false - && (!domain && !username)) { + if (configCheckDisable == false ) { UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"It seems you have not configured any proxy server from settings" delegate:self diff --git a/Classes/LinphoneUI/UISpeakerButton.m b/Classes/LinphoneUI/UISpeakerButton.m index adeb0490e..3ad08dd18 100644 --- a/Classes/LinphoneUI/UISpeakerButton.m +++ b/Classes/LinphoneUI/UISpeakerButton.m @@ -19,9 +19,27 @@ #import "UISpeakerButton.h" #import +#include "linphonecore.h" @implementation UISpeakerButton +static void audioRouteChangeListenerCallback ( + void *inUserData, // 1 + AudioSessionPropertyID inPropertyID, // 2 + UInt32 inPropertyValueSize, // 3 + const void *inPropertyValue // 4 + ) { + if (inPropertyID != kAudioSessionProperty_AudioRouteChange) return; // 5 + [(UISpeakerButton*)inUserData reset]; + +} + +-(void) initWithOnImage:(UIImage*) onImage offImage:(UIImage*) offImage { + [super initWithOnImage:onImage offImage:offImage]; + AudioSessionPropertyID routeChangeID = kAudioSessionProperty_AudioRouteChange; + AudioSessionAddPropertyListener(routeChangeID, audioRouteChangeListenerCallback, self); +} + -(void) onOn { //redirect audio to speaker @@ -38,13 +56,16 @@ , &audioRouteOverride); } -(bool) isInitialStateOn { - UInt32 audioRouteOverride; - UInt32 size = sizeof (audioRouteOverride); - AudioSessionGetProperty (kAudioSessionProperty_OverrideAudioRoute - , &size - , (void*)(&audioRouteOverride)); - return kAudioSessionOverrideAudioRoute_Speaker == audioRouteOverride; - + CFStringRef lNewRoute=CFSTR("Unknown"); + UInt32 lNewRouteSize = sizeof(lNewRoute); + OSStatus lStatus = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute + ,&lNewRouteSize + ,&lNewRoute); + if (!lStatus && CFStringGetLength(lNewRoute) > 0) { + ms_message("Current audio route is [%s]",CFStringGetCStringPtr(lNewRoute, kCFStringEncodingUTF8)); + return (kCFCompareEqualTo == CFStringCompare (lNewRoute,CFSTR("Speaker"),0)); + } else + return false; }