diff --git a/Classes/CallDelegate.h b/Classes/CallDelegate.h index 4541e13b2..216149417 100644 --- a/Classes/CallDelegate.h +++ b/Classes/CallDelegate.h @@ -22,7 +22,6 @@ enum CallDelegateType { CD_UNDEFINED = 0, - CD_NEW_CALL, CD_ZRTP, CD_VIDEO_UPDATE, CD_STOP_VIDEO_ON_LOW_BATTERY, diff --git a/Classes/DialerViewController.m b/Classes/DialerViewController.m index 22247ba79..39b91711d 100644 --- a/Classes/DialerViewController.m +++ b/Classes/DialerViewController.m @@ -54,12 +54,6 @@ - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - //TODO - /*if ([[NSUserDefaults standardUserDefaults] boolForKey:@"enable_first_login_view_preference"] == true) { - myFirstLoginViewController = [[FirstLoginViewController alloc] initWithNibName:@"FirstLoginViewController" - bundle:[NSBundle mainBundle]]; - [self presentModalViewController:myFirstLoginViewController animated:true]; - }*/ // [[LinphoneManager instance] setRegistrationDelegate:self]; //TODO diff --git a/Classes/FirstLoginViewController.h b/Classes/FirstLoginViewController.h index 47ed65665..12e3f0ace 100644 --- a/Classes/FirstLoginViewController.h +++ b/Classes/FirstLoginViewController.h @@ -19,19 +19,21 @@ #import -@interface FirstLoginViewController : UIViewController { - UIButton* ok; - UIButton* site; - UITextField* username; - UIView* activityIndicator; +@interface FirstLoginViewController : UIViewController{ + UIButton* loginButton; + UIButton* siteButton; + UITextField* usernameField; + UITextField* passwordField; + UIView* waitView; } --(void) doOk:(id)sender; +- (IBAction)onLoginClick:(id)sender; +- (IBAction)onSiteClick:(id)sender; -@property (nonatomic, retain) IBOutlet UIButton* ok; -@property (nonatomic, retain) IBOutlet UIButton* site; -@property (nonatomic, retain) IBOutlet UITextField* username; -@property (nonatomic, retain) IBOutlet UITextField* passwd; -@property (nonatomic, retain) IBOutlet UIView* activityIndicator; +@property (nonatomic, retain) IBOutlet UIButton* loginButton; +@property (nonatomic, retain) IBOutlet UIButton* siteButton; +@property (nonatomic, retain) IBOutlet UITextField* usernameField; +@property (nonatomic, retain) IBOutlet UITextField* passwordField; +@property (nonatomic, retain) IBOutlet UIView* waitView; @end diff --git a/Classes/FirstLoginViewController.m b/Classes/FirstLoginViewController.m index cd83a5461..437c76a2a 100644 --- a/Classes/FirstLoginViewController.m +++ b/Classes/FirstLoginViewController.m @@ -23,28 +23,31 @@ @implementation FirstLoginViewController -@synthesize ok; -@synthesize username; -@synthesize passwd; -@synthesize activityIndicator; -@synthesize site; +@synthesize loginButton; +@synthesize siteButton; +@synthesize usernameField; +@synthesize passwordField; +@synthesize waitView; + +- (id)init { + return [super initWithNibName:@"FirstLoginViewController" bundle:[NSBundle mainBundle]]; +} - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - //[username setText:[[NSUserDefaults standardUserDefaults] stringForKey:@"username_preference"]]; - //[passwd setText:[[NSUserDefaults standardUserDefaults] stringForKey:@"password_preference"]]; + [usernameField setText:[[LinphoneManager instance].settingsStore objectForKey:@"username_preference"]]; + [passwordField setText:[[LinphoneManager instance].settingsStore objectForKey:@"password_preference"]]; } --(void) viewDidLoad { - NSString* siteUrl = [[NSUserDefaults standardUserDefaults] stringForKey:@"firt_login_view_url"]; +- (void)viewDidLoad { + NSString* siteUrl = [[LinphoneManager instance].settingsStore objectForKey:@"first_login_view_url"]; if (siteUrl==nil) { siteUrl=@"http://www.linphone.org"; } - [site setTitle:siteUrl forState:UIControlStateNormal]; + [siteButton setTitle:siteUrl forState:UIControlStateNormal]; // Set observer [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(registrationUpdate:) name:@"LinphoneRegistrationUpdate" object:nil]; - } - (void)registrationUpdate: (NSNotification*) notif { @@ -52,36 +55,36 @@ switch (state) { case LinphoneRegistrationOk: { - [[NSUserDefaults standardUserDefaults] setBool:false forKey:@"enable_first_login_view_preference"]; - [self.activityIndicator setHidden:true]; - [self dismissModalViewControllerAnimated:YES]; + [[LinphoneManager instance].settingsStore setBool:false forKey:@"enable_first_login_view_preference"]; + [self.waitView setHidden:true]; + [[LinphoneManager instance] changeView:PhoneView_Dialer]; break; } case LinphoneRegistrationNone: case LinphoneRegistrationCleared: { - [self.activityIndicator setHidden:true]; + [self.waitView setHidden:true]; break; } case LinphoneRegistrationFailed: { - [self.activityIndicator setHidden:true]; + [self.waitView setHidden:true]; //default behavior if no registration delegates - //UIAlertView* error = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Registration failure for user %@",user] - // message:reason - // delegate:nil - // cancelButtonTitle:@"Continue" - // otherButtonTitles:nil ,nil]; - //[error show]; - //[error release]; + /*UIAlertView* error = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Registration failure for user %@", usernameField.text] + message:[notif.userInfo objectForKey: @"message"] + delegate:nil + cancelButtonTitle:@"Continue" + otherButtonTitles:nil,nil]; + [error show]; + [error release];*/ //erase uername passwd [[LinphoneManager instance].settingsStore setObject:Nil forKey:@"username_preference"]; [[LinphoneManager instance].settingsStore setObject:Nil forKey:@"password_preference"]; break; } case LinphoneRegistrationProgress: { - [self.activityIndicator setHidden:false]; + [self.waitView setHidden:false]; break; } default: break; @@ -90,27 +93,29 @@ - (void)dealloc { [super dealloc]; - [ok dealloc]; - [site dealloc]; - [username dealloc]; - [activityIndicator dealloc]; + [loginButton dealloc]; + [siteButton dealloc]; + [usernameField dealloc]; + [passwordField dealloc]; + [waitView dealloc]; [[NSNotificationCenter defaultCenter] removeObserver:self]; } -- (void) viewDidUnload { +- (void)viewDidUnload { [[NSNotificationCenter defaultCenter] removeObserver:self]; } --(void) doOk:(id)sender { - if (sender == site) { - NSURL *url = [NSURL URLWithString:site.titleLabel.text]; - [[UIApplication sharedApplication] openURL:url]; - return; - } +- (void)onSiteClick:(id)sender { + NSURL *url = [NSURL URLWithString:siteButton.titleLabel.text]; + [[UIApplication sharedApplication] openURL:url]; + return; +} + +- (void)onLoginClick:(id)sender { NSString* errorMessage=nil; - if ([username.text length]==0 ) { + if ([usernameField.text length]==0 ) { errorMessage=NSLocalizedString(@"Enter your username",nil); - } else if ([passwd.text length]==0 ) { + } else if ([passwordField.text length]==0 ) { errorMessage=NSLocalizedString(@"Enter your password",nil); } @@ -124,12 +129,11 @@ [error show]; [error release]; } else { - [[LinphoneManager instance].settingsStore setObject:username.text forKey:@"username_preference"]; - [[LinphoneManager instance].settingsStore setObject:passwd.text forKey:@"password_preference"]; - [self.activityIndicator setHidden:false]; + [[LinphoneManager instance].settingsStore setObject:usernameField.text forKey:@"username_preference"]; + [[LinphoneManager instance].settingsStore setObject:passwordField.text forKey:@"password_preference"]; + [self.waitView setHidden:false]; + [[LinphoneManager instance].settingsStore synchronize]; }; - - } - (BOOL)textFieldShouldReturn:(UITextField *)theTextField { @@ -138,5 +142,4 @@ return YES; } - @end diff --git a/Classes/FirstLoginViewController.xib b/Classes/FirstLoginViewController.xib index 5ab733adc..6f148cbb2 100644 --- a/Classes/FirstLoginViewController.xib +++ b/Classes/FirstLoginViewController.xib @@ -2,23 +2,22 @@ 784 - 10K549 - 1938 - 1038.36 - 461.00 + 11E53 + 2182 + 1138.47 + 569.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 933 + 1181 YES - IBUIView - IBUIImageView - IBUIViewController - IBProxyObject IBUIActivityIndicatorView - IBUITextField IBUIButton + IBUIImageView + IBUIView + IBUITextField + IBProxyObject YES @@ -38,212 +37,210 @@ IBFirstResponder IBCocoaTouchFramework - - - - 292 - - YES - - - 292 - {{0, -20}, {360, 480}} - - - NO - NO - 9 - NO - IBCocoaTouchFramework - - NSImage - wallpaper_iphone_320x480.png - - - - - -2147483356 - {{60, 400}, {200, 37}} - - - NO - NO - IBCocoaTouchFramework - 0 - 0 - - 3 - MQA - - - 1 - MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA - - - 3 - MC41AA - - - Helvetica-Bold - Helvetica - 2 - 15 - - - Helvetica-Bold - 15 - 16 - - - - - 292 - {{60, 200}, {200, 31}} - - - NO - NO - IBCocoaTouchFramework - 0 - 0 - - 3 - Password - - 3 - MAA - - 2 - - - YES - YES - 17 - - 1 - YES - IBCocoaTouchFramework - - - 1 - 12 - - - Helvetica - 12 - 16 - - - - - 292 - {{60, 150}, {200, 31}} - - - NO - NO - IBCocoaTouchFramework - 0 - - 3 - Username - - 3 - MAA - - - YES - 17 - - 1 - IBCocoaTouchFramework - - - - - - - 292 - {{60, 300}, {200, 37}} - - - NO - NO - IBCocoaTouchFramework - 0 - 0 - 1 - Login - - - 5 - MSAwLjY2MDAwMDAyNjIgMCAwAA - - 3 - - 1 0.66 0 0 1 - - - - 2 - 2 - - - Helvetica-Bold - 18 - 16 - - - - - -2147483356 - - YES - - - 292 - {{142, 211}, {37, 37}} - - - NO - NO - NO - IBCocoaTouchFramework - NO - YES - 0 - - - {320, 460} - - - - 3 - MSAwLjY2AA - - - NO - IBCocoaTouchFramework + + + 292 + + YES + + + 292 + {360, 480} + + + + NO + NO + 9 + NO + IBCocoaTouchFramework + + NSImage + wallpaper_iphone_320x480.png - {{0, 20}, {320, 460}} - - - - 3 - MQA - + + + -2147483356 + {{60, 420}, {200, 37}} + + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 3 + MQA + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + 3 + MC41AA + + + Helvetica-Bold + Helvetica + 2 + 15 + + + Helvetica-Bold + 15 + 16 + + + + + 292 + {{60, 220}, {200, 31}} + + + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 3 + Password + + 3 + MAA + + 2 + + + YES + YES + 17 + + 1 + YES + IBCocoaTouchFramework + + + 1 + 12 + + + Helvetica + 12 + 16 + + + + + 292 + {{60, 170}, {200, 31}} + + + + NO + NO + IBCocoaTouchFramework + 0 + + 3 + Username + + 3 + MAA + + + YES + 17 + + 1 + IBCocoaTouchFramework + + + + + + + 292 + {{60, 320}, {200, 37}} + + + + NO + NO + IBCocoaTouchFramework + 0 + 0 + 1 + Login + + + 5 + MSAwLjY2MDAwMDAyNjIgMCAwAA + + 3 + + 1 0.66 0 0 1 + + + + 2 + 2 + + + Helvetica-Bold + 18 + 16 + + + + + -2147483356 + + YES + + + 292 + {{142, 211}, {37, 37}} + + + + NO + NO + NO + IBCocoaTouchFramework + NO + YES + 0 + + + {320, 460} + + + + + 3 + MSAwLjY2AA + + + NO + IBCocoaTouchFramework - - IBCocoaTouchFramework - - - 1 - 1 + {320, 460} + + + + _NS:9 + + 3 + MQA + IBCocoaTouchFramework - NO @@ -253,41 +250,49 @@ view - + - 3 + 56 - passwd - - - - 15 - - - - activityIndicator + waitView - 33 + 57 - username - - - - 38 - - - - site + siteButton - 36 + 58 + + + + usernameField + + + + 59 + + + + passwordField + + + + 60 + + + + loginButton + + + + 61 @@ -307,21 +312,21 @@ - doOk: + onLoginClick: 7 - 20 + 62 - doOk: + onSiteClick: 7 - 37 + 63 @@ -347,49 +352,48 @@ - 4 - + 55 + YES - + + + + + + - 1 - - - YES - - - - - - - - + 5 + + + background - 12 - - - - - 6 - - - username + 35 + + + siteButton 8 - - passwd + + passwordField - 5 - - + 6 + + + usernameField + + + 12 + + + loginButton 31 @@ -398,19 +402,14 @@ YES - - wait + + waitView 32 - - - 35 - - - site + activityIndicator @@ -422,34 +421,23 @@ -1.IBPluginDependency -2.CustomClassName -2.IBPluginDependency - 1.IBPluginDependency - 1.IBUserGuides 12.IBPluginDependency 12.IBUIButtonInspectorSelectedStateConfigurationMetadataKey 31.IBPluginDependency 32.IBPluginDependency 35.IBPluginDependency - 4.IBPluginDependency 5.IBPluginDependency + 55.IBPluginDependency 6.IBPluginDependency 8.IBPluginDependency - + YES FirstLoginViewController com.apple.InterfaceBuilder.IBCocoaTouchPlugin UIResponder com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - YES - - - 104 - 0 - - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -472,9 +460,106 @@ - 54 + 63 + + + + YES + + FirstLoginViewController + UIViewController + + YES + + YES + onLoginClick: + onSiteClick: + + + YES + id + id + + + + YES + + YES + onLoginClick: + onSiteClick: + + + YES + + onLoginClick: + id + + + onSiteClick: + id + + + + + YES + + YES + loginButton + passwordField + siteButton + usernameField + waitView + + + YES + UIButton + UITextField + UIButton + UITextField + UIView + + + + YES + + YES + loginButton + passwordField + siteButton + usernameField + waitView + + + YES + + loginButton + UIButton + + + passwordField + UITextField + + + siteButton + UIButton + + + usernameField + UITextField + + + waitView + UIView + + + + + IBProjectSource + ./Classes/FirstLoginViewController.h + + + - 0 IBCocoaTouchFramework @@ -483,7 +568,7 @@ com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 @@ -495,6 +580,6 @@ wallpaper_iphone_320x480.png {320, 480} - 933 + 1181 diff --git a/Classes/IncomingCallViewController.h b/Classes/IncomingCallViewController.h index cd1555006..ba2a9563a 100644 --- a/Classes/IncomingCallViewController.h +++ b/Classes/IncomingCallViewController.h @@ -19,13 +19,31 @@ #import -@interface IncomingCallViewController : UIViewController { +#import "UIModalViewController.h" + +#include "linphonecore.h" + +typedef enum _IncomingCallStates { + IncomingCall_Accepted, + IncomingCall_Decline, + IncomingCall_Aborted +} IncomingCallStats; + +@interface IncomingCallViewController : UIModalViewController { +@private UILabel* addressLabel; + UIImageView* avatarImage; + LinphoneCall *call; } @property (nonatomic, retain) IBOutlet UILabel* addressLabel; +@property (nonatomic, retain) IBOutlet UIImageView* avatarImage; - (IBAction)onAcceptClick:(id) event; - (IBAction)onDeclineClick:(id) event; +- (void)update:(LinphoneCall*)call; + +- (LinphoneCall*) getCall; + @end diff --git a/Classes/IncomingCallViewController.m b/Classes/IncomingCallViewController.m index 0e8a2acb3..109a2577d 100644 --- a/Classes/IncomingCallViewController.m +++ b/Classes/IncomingCallViewController.m @@ -18,21 +18,62 @@ */ #import "IncomingCallViewController.h" +#import "LinphoneManager.h" @implementation IncomingCallViewController @synthesize addressLabel; +@synthesize avatarImage; - (id)init { - return [super initWithNibName:@"IncomingCallViewController" bundle:[NSBundle mainBundle]]; + self = [super initWithNibName:@"IncomingCallViewController" bundle:[NSBundle mainBundle]]; + if(self) { + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(callUpdate:) + name:@"LinphoneCallUpdate" + object:nil]; + } + return self; } -- (IBAction)onAcceptClick:(id) event { +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [super dealloc]; } -- (IBAction)onDeclineClick:(id) event { +- (void)callUpdate:(NSNotification*)notif { + LinphoneCall *acall = [[notif.userInfo objectForKey: @"call"] pointerValue]; + LinphoneCallState astate = [[notif.userInfo objectForKey: @"state"] intValue]; + if(call == acall && (astate == LinphoneCallEnd || astate == LinphoneCallError)) { + [self dismiss: IncomingCall_Aborted]; + } +} +- (IBAction)onAcceptClick:(id)event { + linphone_core_accept_call([LinphoneManager getLc], call); + [self dismiss: IncomingCall_Accepted]; +} + +- (IBAction)onDeclineClick:(id)event { + linphone_core_terminate_call([LinphoneManager getLc], call); + [self dismiss: IncomingCall_Decline]; +} + +- (void)update:(LinphoneCall*)acall { + [self view]; //Force view load + + call = acall; + const char* userNameChars=linphone_address_get_username(linphone_call_get_remote_address(call)); + NSString* userName = userNameChars?[[[NSString alloc] initWithUTF8String:userNameChars] autorelease]:NSLocalizedString(@"Unknown",nil); + const char* displayNameChars = linphone_address_get_display_name(linphone_call_get_remote_address(call)); + NSString* displayName = [displayNameChars?[[NSString alloc] initWithUTF8String:displayNameChars]:@"" autorelease]; + + [addressLabel setText:([displayName length]>0)?displayName:userName]; +} + +- (LinphoneCall*) getCall { + return call; } @end diff --git a/Classes/IncomingCallViewController.xib b/Classes/IncomingCallViewController.xib index b0cdd3cbf..dbd4b76ca 100644 --- a/Classes/IncomingCallViewController.xib +++ b/Classes/IncomingCallViewController.xib @@ -1,7 +1,7 @@ - 1280 + 1296 11E53 2182 1138.47 @@ -39,7 +39,7 @@ - 292 + 288 @@ -62,7 +62,7 @@ {{0, 47}, {320, 63}} - + _NS:9 NO IBCocoaTouchFramework @@ -93,7 +93,7 @@ {{10, 53}, {300, 51}} - + _NS:9 NO NO @@ -4488,7 +4488,7 @@ AAgAAAAIAAIACAACAAAAAgAAAAEAAQABAAE - + 3 MCAwAA @@ -4508,24 +4508,48 @@ AAgAAAAIAAIACAACAAAAAgAAAAEAAQABAAE 16 + + + 292 + {{0, 96}, {320, 262}} + + + + _NS:9 + NO + IBCocoaTouchFramework + + NSImage + ombre-cotes-avatar.png + + + + + 292 + {{80, 113}, {160, 170}} + + + + _NS:9 + NO + IBCocoaTouchFramework + + NSImage + avatar-inconnu.png + + - {320, 110} + {320, 395} _NS:9 - - 3 - MQA - - 2 - - + IBCocoaTouchFramework - 292 + 264 @@ -4538,7 +4562,9 @@ AAgAAAAIAAIACAACAAAAAgAAAAEAAQABAAE 3 MQA - + + 2 + -1 NO @@ -4629,10 +4655,10 @@ AAgAAAAIAAIACAACAAAAAgAAAAEAAQABAAE - 3 - MQA - + 1 + MC45Njg2Mjc0NTEgMC45Njg2Mjc0NTEgMC45Njg2Mjc0NTEAA + NO IBCocoaTouchFramework @@ -4655,6 +4681,14 @@ AAgAAAAIAAIACAACAAAAAgAAAAEAAQABAAE 14 + + + avatarImage + + + + 20 + onDeclineClick: @@ -4738,6 +4772,8 @@ AAgAAAAIAAIACAACAAAAAgAAAAEAAQABAAE + + @@ -4759,6 +4795,18 @@ AAgAAAAIAAIACAACAAAAAgAAAAEAAQABAAE otherBackground + + 18 + + + avatarShadowImage + + + 19 + + + avatarImage + @@ -4770,6 +4818,8 @@ AAgAAAAIAAIACAACAAAAAgAAAAEAAQABAAE com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -4783,7 +4833,7 @@ AAgAAAAIAAIACAACAAAAAgAAAAEAAQABAAE - 16 + 20 @@ -4804,17 +4854,20 @@ AAgAAAAIAAIACAACAAAAAgAAAAEAAQABAAE id - - addressLabel - UILabel - - - addressLabel - + + UILabel + UIImageView + + + addressLabel UILabel - + + avatarImage + UIImageView + + IBProjectSource ./Classes/IncomingCallViewController.h @@ -4824,13 +4877,19 @@ AAgAAAAIAAIACAACAAAAAgAAAAEAAQABAAE 0 IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + YES 3 + {320, 339} {640, 125} {640, 135} {320, 154} {320, 154} + {640, 523} {320, 154} {320, 154} diff --git a/Classes/LinphoneApp.xib b/Classes/LinphoneApp.xib index 5e580fba6..ed352e92e 100644 --- a/Classes/LinphoneApp.xib +++ b/Classes/LinphoneApp.xib @@ -54,6 +54,7 @@ YES + PhoneMainView 1 @@ -148,77 +149,57 @@ - - IASKAbstractSettingsStore - NSObject - - IBProjectSource - ./Classes/IASKAbstractSettingsStore.h - - LinphoneAppDelegate NSObject - - LinphoneCoreSettingsStore - UIWindow - - - - settings - LinphoneCoreSettingsStore - - + + window + UIWindow + + + window + window UIWindow - + IBProjectSource ./Classes/LinphoneAppDelegate.h - LinphoneCoreSettingsStore - IASKAbstractSettingsStore + PhoneMainView + UIViewController + + mainViewController + UICompositeViewController + + + mainViewController + + mainViewController + UICompositeViewController + + IBProjectSource - ./Classes/LinphoneCoreSettingsStore.h + ./Classes/PhoneMainView.h - PhoneMainView + UICompositeViewController UIViewController - UIViewController UIView - UIViewController - UIViewController - UIViewController UIView UIView - - callTabBarController - UIViewController - contentView UIView - - incomingCallTabBarController - UIViewController - - - mainTabBarController - UIViewController - - - stateBarController - UIViewController - stateBarView UIView @@ -230,7 +211,7 @@ IBProjectSource - ./Classes/PhoneMainView.h + ./Classes/UICompositeViewController.h diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 351483b88..079869ac6 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -94,7 +94,7 @@ int __aeabi_idiv(int a, int b) { - (void)applicationDidBecomeActive:(UIApplication *)application { if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] && [UIApplication sharedApplication].applicationState == UIApplicationStateBackground - && [[NSUserDefaults standardUserDefaults] boolForKey:@"disable_autoboot_preference"]) { + && ![[NSUserDefaults standardUserDefaults] boolForKey:@"start_at_boot_preference"]) { // autoboot disabled, doing nothing return; } else if ([LinphoneManager instance] == nil) { @@ -133,13 +133,21 @@ int __aeabi_idiv(int a, int b) { } - (void)loadDefaultSettings:(NSDictionary *) appDefaults { + for(NSString* key in appDefaults){ + NSLog(@"Overload %@ to in app settings.", key); + [[[LinphoneManager instance] settingsStore] setObject:[appDefaults objectForKey:key] forKey:key]; + } [[[LinphoneManager instance] settingsStore] synchronize]; } - (void)setupUI { - - // Change to default view - [[LinphoneManager instance] changeView: PhoneView_Dialer]; + if ([[LinphoneManager instance].settingsStore boolForKey:@"enable_first_login_view_preference"] == true) { + // Change to fist login view + [[LinphoneManager instance] changeView: PhoneView_FirstLoginView]; + } else { + // Change to default view + [[LinphoneManager instance] changeView: PhoneView_Dialer]; + } [UIDevice currentDevice].batteryMonitoringEnabled = YES; } @@ -174,11 +182,11 @@ int __aeabi_idiv(int a, int b) { /* explicitely instanciate LinphoneManager */ LinphoneManager* lm = [[LinphoneManager alloc] init]; assert(lm == [LinphoneManager instance]); - - [self setupUI]; [[LinphoneManager instance] startLibLinphone]; + [self setupUI]; + [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound]; [self setupGSMInteraction]; @@ -200,7 +208,7 @@ int __aeabi_idiv(int a, int b) { ms_warning("Local notification received with nil call"); return; } - linphone_core_accept_call([LinphoneManager getLc], call); + linphone_core_accept_call([LinphoneManager getLc], call); } @end diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 3b59c41b2..ec00af1cf 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -25,62 +25,62 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); @implementation LinphoneCoreSettingsStore -- (void)handleMigration{ - +- (void)handleMigration { NSUserDefaults *oldconfig=[NSUserDefaults standardUserDefaults]; NSArray *allkeys=[[oldconfig dictionaryRepresentation] allKeys]; - for(NSString* key in allkeys){ - NSLog(@"Migrating old config item %@ to in app settings.",key); - [self setObject:[oldconfig objectForKey:key] forKey:key]; - } - [self synchronize]; - NSLog(@"Migration done"); + for(NSString* key in allkeys){ + NSLog(@"Migrating old config item %@ to in app settings.",key); + [self setObject:[oldconfig objectForKey:key] forKey:key]; + } + [self synchronize]; + NSLog(@"Migration done"); } -- (id)init{ +- (id)init { self = [super init]; if (self){ dict=[[NSMutableDictionary alloc] init]; changedDict=[[NSMutableDictionary alloc] init]; - LinphoneCore *lc=[LinphoneManager getLc]; - if (lp_config_get_int(linphone_core_get_config(lc),"app","config_migrated",0)==0){ + [self transformLinphoneCoreToKeys]; + LinphoneCore *lc=[LinphoneManager getLc]; + if (lp_config_get_int(linphone_core_get_config(lc),"app","config_migrated",0) == 0) { [self handleMigration]; lp_config_set_int(linphone_core_get_config(lc),"app","config_migrated",1); } - [self transformLinphoneCoreToKeys]; } return self; } -- (void)dealloc{ - [super dealloc]; +- (void)dealloc { [dict release]; [changedDict release]; + [super dealloc]; } -- (void)transformKeysToLinphoneCore{ +- (void)transformKeysToLinphoneCore { //LinphoneCore *lc=[LinphoneManager getLc]; } -- (void)setString:(const char*)value forKey:(NSString*)key{ +- (void)setString:(const char*)value forKey:(NSString*)key { id obj=Nil; if (value) obj=[[NSString alloc] initWithCString:value encoding:[NSString defaultCStringEncoding] ]; [self setObject: obj forKey:key]; } -- (NSString*)stringForKey:(NSString*) key{ +- (NSString*)stringForKey:(NSString*) key { return [self objectForKey: key]; } -- (void)transformCodecsToKeys: (const MSList *)codecs{ +- (void)transformCodecsToKeys: (const MSList *)codecs { LinphoneCore *lc=[LinphoneManager getLc]; const MSList *elem=codecs; for(;elem!=NULL;elem=elem->next){ PayloadType *pt=(PayloadType*)elem->data; NSString *pref=[LinphoneManager getPreferenceForCodec:pt->mime_type withRate:pt->clock_rate]; if (pref){ - [self setBool: linphone_core_payload_type_enabled(lc,pt) forKey: pref]; + bool_t value = linphone_core_payload_type_enabled(lc,pt); + [self setBool:value forKey: pref]; }else{ ms_warning("Codec %s/%i supported by core is not shown in iOS app config view.", pt->mime_type,pt->clock_rate); @@ -88,7 +88,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); } } -- (void)transformLinphoneCoreToKeys{ +- (void)transformLinphoneCoreToKeys { LinphoneCore *lc=[LinphoneManager getLc]; LinphoneProxyConfig *cfg=NULL; linphone_core_get_default_proxy(lc,&cfg); @@ -157,11 +157,11 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); } [self setString:val forKey:@"media_encryption_preference"]; } - - [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","debugenable_preference",0) forKey:@"debugenable_preference"]; - [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","check_config_disable_preference",0) forKey:@"check_config_disable_preference"]; - [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","wifi_only_preference",0) forKey:@"wifi_only_preference"]; - [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","backgroundmode_preference",TRUE) forKey:@"backgroundmode_preference"]; + [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","enable_first_login_view_preference", 0) forKey:@"enable_first_login_view_preference"]; + [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","debugenable_preference", 0) forKey:@"debugenable_preference"]; + [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","check_config_disable_preference", 0) forKey:@"check_config_disable_preference"]; + [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","wifi_only_preference", 0) forKey:@"wifi_only_preference"]; + [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","backgroundmode_preference", TRUE) forKey:@"backgroundmode_preference"]; /*keep this one also in the standardUserDefaults so that it can be read before starting liblinphone*/ BOOL start_at_boot; if ([[NSUserDefaults standardUserDefaults] objectForKey:@"start_at_boot_preference"]==Nil) @@ -169,8 +169,6 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); else start_at_boot=[[NSUserDefaults standardUserDefaults] boolForKey:@"start_at_boot_preference"]; [self setBool: start_at_boot forKey:@"start_at_boot_preference"]; - - if (linphone_core_tunnel_available()){ /*FIXME: enhance linphonecore API to handle tunnel more easily in applications */ //LinphoneTunnel *tun=linphone_core_get_tunnel(lc); @@ -200,14 +198,14 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); return [dict valueForKey:key]; } -- (BOOL)valueChangedForKey:(NSString*)key{ +- (BOOL)valueChangedForKey:(NSString*)key { return [ [changedDict valueForKey:key] boolValue]; } -- (void)synchronizeAccount{ - LinphoneCore *lc=[LinphoneManager getLc]; +- (void)synchronizeAccount { + LinphoneCore *lc = [LinphoneManager getLc]; LinphoneManager* lLinphoneMgr = [LinphoneManager instance]; - LinphoneProxyConfig* proxyCfg=NULL; + LinphoneProxyConfig* proxyCfg = NULL; /* unregister before modifying any settings */ { linphone_core_get_default_proxy(lc, &proxyCfg); @@ -370,16 +368,16 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); else linphone_core_set_media_encryption(lc, LinphoneMediaEncryptionNone); NSString* stun_server = [self stringForKey:@"stun_preference"]; - if ([stun_server length]>0){ + if ([stun_server length] > 0){ linphone_core_set_stun_server(lc,[stun_server cStringUsingEncoding:[NSString defaultCStringEncoding]]); linphone_core_set_firewall_policy(lc, LinphonePolicyUseStun); - }else{ + } else { linphone_core_set_stun_server(lc, NULL); linphone_core_set_firewall_policy(lc, LinphonePolicyNoFirewall); } LinphoneVideoPolicy policy; - policy.automatically_accept = [self boolForKey:@"start_video_preference"];; + policy.automatically_accept = [self boolForKey:@"start_video_preference"]; policy.automatically_initiate = [self boolForKey:@"start_video_preference"]; linphone_core_set_video_policy(lc, &policy); @@ -391,21 +389,24 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); if (backgroundSupported) { isbackgroundModeEnabled = [self boolForKey:@"backgroundmode_preference"]; } else { - isbackgroundModeEnabled=false; + isbackgroundModeEnabled = false; } - lp_config_set_int(linphone_core_get_config(lc),"app","backgroundmode_preference",isbackgroundModeEnabled); + lp_config_set_int(linphone_core_get_config(lc),"app","backgroundmode_preference", isbackgroundModeEnabled); - BOOL debugmode=[self boolForKey:@"debugenable_preference"]; - lp_config_set_int(linphone_core_get_config(lc),"app","debugenable_preference",debugmode); + BOOL firstloginview = [self boolForKey:@"enable_first_login_view_preference"]; + lp_config_set_int(linphone_core_get_config(lc),"app","enable_first_login_view_preference", firstloginview); + + BOOL debugmode = [self boolForKey:@"debugenable_preference"]; + lp_config_set_int(linphone_core_get_config(lc),"app","debugenable_preference", debugmode); if (debugmode) linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler); else linphone_core_disable_logs(); /*keep this one also in the standardUserDefaults so that it can be read before starting liblinphone*/ - BOOL start_at_boot=[self boolForKey:@"start_at_boot_preference"]; + BOOL start_at_boot = [self boolForKey:@"start_at_boot_preference"]; [[NSUserDefaults standardUserDefaults] setBool: start_at_boot forKey:@"start_at_boot_preference"]; [changedDict release]; - changedDict=[[NSMutableDictionary alloc] init]; + changedDict = [[NSMutableDictionary alloc] init]; return YES; } diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index 270a7be0e..9975dad3d 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -29,6 +29,7 @@ #include "linphonecore.h" typedef enum _PhoneView { + PhoneView_FirstLoginView, PhoneView_Dialer, PhoneView_History, PhoneView_Settings, diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 8cde595e9..15cbf418d 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -352,16 +352,6 @@ static LinphoneCoreVTable linphonec_vtable = { .transfer_state_changed=linphone_iphone_transfer_state_changed }; - -- (void)configurePayloadType:(const char*) type fromPrefKey: (NSString*)key withRate:(int)rate { - if ([[NSUserDefaults standardUserDefaults] boolForKey:key]) { - PayloadType* pt; - if((pt = linphone_core_find_payload_type(theLinphoneCore,type,rate))) { - linphone_core_enable_payload_type(theLinphoneCore,pt, TRUE); - } - } -} - - (void)kickOffNetworkConnection { /*start a new thread to avoid blocking the main ui in case of peer host failure*/ [NSThread detachNewThreadSelector:@selector(runNetworkConnection) toTarget:self withObject:nil]; @@ -471,7 +461,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach // no proxy configured alert - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 1) { - [[NSUserDefaults standardUserDefaults] setBool:true forKey:@"check_config_disable_preference"]; + [[[LinphoneManager instance] settingsStore] setBool:true forKey:@"check_config_disable_preference"]; } } @@ -498,7 +488,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach linphone_core_get_default_proxy(theLinphoneCore, &proxyCfg); linphone_core_stop_dtmf_stream(theLinphoneCore); - if (proxyCfg && lp_config_get_int(linphone_core_get_config(theLinphoneCore),"app","backgroundmode_preference",0)) { + if (proxyCfg && [settingsStore boolForKey:@"backgroundmode_preference"]) { //For registration register linphone_core_refresh_registers(theLinphoneCore); diff --git a/Classes/LinphoneUI/FastAddressBook.m b/Classes/LinphoneUI/FastAddressBook.m index e1e3334c6..5cf73de15 100644 --- a/Classes/LinphoneUI/FastAddressBook.m +++ b/Classes/LinphoneUI/FastAddressBook.m @@ -18,6 +18,8 @@ */ #import "FastAddressBook.h" +#import "LinphoneManager.h" + @implementation FastAddressBook @synthesize addressBook; @@ -30,7 +32,7 @@ +(NSString*) appendCountryCodeIfPossible:(NSString*) number { if (![number hasPrefix:@"+"] && ![number hasPrefix:@"00"]) { - NSString* lCountryCode = [[NSUserDefaults standardUserDefaults] stringForKey:@"countrycode_preference"]; + NSString* lCountryCode = [[LinphoneManager instance].settingsStore objectForKey:@"countrycode_preference"]; if (lCountryCode && [lCountryCode length]>0) { //append country code return [lCountryCode stringByAppendingString:number]; diff --git a/Classes/LinphoneUI/UICompositeViewController.m b/Classes/LinphoneUI/UICompositeViewController.m index 895f0f06a..6e7cba69b 100644 --- a/Classes/LinphoneUI/UICompositeViewController.m +++ b/Classes/LinphoneUI/UICompositeViewController.m @@ -130,6 +130,8 @@ return controller; } +#define IPHONE_STATUSBAR_HEIGHT 20 + - (void)update: (UICompositeViewDescription*) description tabBar:(NSNumber*)tabBar fullscreen:(NSNumber*)fullscreen { // Copy view description @@ -198,25 +200,22 @@ // Resize StateBar CGRect stateBarFrame = stateBarView.frame; + int origin = 0; if(currentViewDescription->fullscreen) - stateBarFrame.origin.y = -20; - else - stateBarFrame.origin.y = 0; + origin = -IPHONE_STATUSBAR_HEIGHT; if(stateBarViewController != nil && currentViewDescription->stateBarEnabled) { - stateBarView.hidden = false; - [stateBarView setFrame: stateBarFrame]; - contentFrame.origin.y = stateBarFrame.size.height + stateBarFrame.origin.y; + contentFrame.origin.y = origin + stateBarFrame.size.height; + stateBarFrame.origin.y = origin; } else { - stateBarView.hidden = true; - contentFrame.origin.y = stateBarFrame.origin.y; + contentFrame.origin.y = origin; + stateBarFrame.origin.y = origin - stateBarFrame.size.height; } // Resize TabBar CGRect tabFrame = tabBarView.frame; if(tabBarViewController != nil && currentViewDescription->tabBarEnabled) { - tabBarView.hidden = false; - tabFrame.origin.y = [[UIScreen mainScreen] bounds].size.height - 20; + tabFrame.origin.y = [[UIScreen mainScreen] bounds].size.height - IPHONE_STATUSBAR_HEIGHT; tabFrame.origin.x = [[UIScreen mainScreen] bounds].size.width; tabFrame.size.height = tabBarViewController.view.frame.size.height; tabFrame.size.width = tabBarViewController.view.frame.size.width; @@ -230,11 +229,10 @@ } } } else { - tabBarView.hidden = true; contentFrame.size.height = tabFrame.origin.y + tabFrame.size.height; if(currentViewDescription->fullscreen) - contentFrame.size.height += 20; - tabFrame.origin.y = [[UIScreen mainScreen] bounds].size.height - 20; + contentFrame.size.height += IPHONE_STATUSBAR_HEIGHT; + tabFrame.origin.y = [[UIScreen mainScreen] bounds].size.height - IPHONE_STATUSBAR_HEIGHT; } // Resize innerView @@ -246,6 +244,7 @@ [contentView setFrame: contentFrame]; [innerView setFrame: innerContentFrame]; [tabBarView setFrame: tabFrame]; + [stateBarView setFrame: stateBarFrame]; // Commit animation if(tabBar != nil || fullscreen != nil) { diff --git a/Classes/LinphoneUI/UIModalViewController.h b/Classes/LinphoneUI/UIModalViewController.h new file mode 100644 index 000000000..f422b632a --- /dev/null +++ b/Classes/LinphoneUI/UIModalViewController.h @@ -0,0 +1,38 @@ +/* UIModalViewController.h + * + * Copyright (C) 2012 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#import + +@class UIModalViewController; + +@protocol UIModalViewDelegate + +- (void)modalViewDismiss:(UIModalViewController*)controller value:(int)value; + +@end + +@interface UIModalViewController : UIViewController { + id modalDelegate; +} + +- (void)setModalDelegate:(id)delegate; +- (void)dismiss:(int)value; +- (void)dismiss; + +@end diff --git a/Classes/LinphoneUI/UIModalViewController.m b/Classes/LinphoneUI/UIModalViewController.m new file mode 100644 index 000000000..6207ccbb8 --- /dev/null +++ b/Classes/LinphoneUI/UIModalViewController.m @@ -0,0 +1,38 @@ +/* UIModalViewController.h + * + * Copyright (C) 2012 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#import "UIModalViewController.h" + +@implementation UIModalViewController + +- (void)dismiss:(int)value { + if(modalDelegate != nil) + [modalDelegate modalViewDismiss:self value:value]; +} + +- (void)dismiss{ + if(modalDelegate != nil) + [modalDelegate modalViewDismiss:self value:0]; +} + +- (void)setModalDelegate:(id)delegate { + modalDelegate = delegate; +} + +@end diff --git a/Classes/PhoneMainView.h b/Classes/PhoneMainView.h index c9951908b..b8dc86c26 100644 --- a/Classes/PhoneMainView.h +++ b/Classes/PhoneMainView.h @@ -22,20 +22,23 @@ #import "LinphoneManager.h" #import "CallDelegate.h" #import "UICompositeViewController.h" +#import "UIModalViewController.h" -@interface PhoneMainView : UIViewController { - UICompositeViewController *mainViewController; - UICompositeViewController *modalViewController; - +@interface PhoneMainView : UIViewController { @private + UICompositeViewController *mainViewController; + + NSMutableArray *modalControllers; + NSMutableDictionary *viewDescriptions; PhoneView currentPhoneView; UIActionSheet *incomingCallActionSheet; UIActionSheet *batteryActionSheet; + + int loadCount; } @property (nonatomic, retain) IBOutlet UICompositeViewController *mainViewController; -@property (nonatomic, retain) IBOutlet UICompositeViewController *modalViewController; @end diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index e286a2786..2992fbcbc 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -20,23 +20,23 @@ #import #import "PhoneMainView.h" -#import "DialerViewController.h" -#import "HistoryViewController.h" -#import "ContactsViewController.h" + +#import "FirstLoginViewController.h" #import "IncomingCallViewController.h" -#import "InCallViewController.h" -#import "SettingsViewController.h" -#import "ChatViewController.h" #import "AbstractCall.h" @implementation PhoneMainView @synthesize mainViewController; -@synthesize modalViewController; - (void)myInit { - self->currentPhoneView = -1; + currentPhoneView = -1; + loadCount = 0; // For avoiding IOS 4 bug + + // Init view descriptions + viewDescriptions = [[NSMutableDictionary alloc] init]; + modalControllers = [[NSMutableArray alloc] init]; } - (id)init { @@ -95,13 +95,13 @@ } - (void)viewDidLoad { + // Avoid IOS 4 bug + if(self->loadCount++ > 0) + return; + [super viewDidLoad]; - [[self view] addSubview: mainViewController.view]; - // Init view descriptions - viewDescriptions = [[NSMutableDictionary alloc] init]; - // // Main View // @@ -140,18 +140,6 @@ historyDescription->fullscreen = false; [viewDescriptions setObject:historyDescription forKey:[NSNumber numberWithInt: PhoneView_History]]; - // - // IncomingCall View - // - UICompositeViewDescription *incomingCallDescription = [UICompositeViewDescription alloc]; - incomingCallDescription->content = @"IncomingCallViewController"; - incomingCallDescription->tabBar = nil; - incomingCallDescription->tabBarEnabled = false; - incomingCallDescription->stateBar = @"UIStateBar"; - incomingCallDescription->stateBarEnabled = true; - incomingCallDescription->fullscreen = false; - [viewDescriptions setObject:incomingCallDescription forKey:[NSNumber numberWithInt: PhoneView_IncomingCall]]; - // // InCall View // @@ -188,6 +176,18 @@ chatDescription->stateBarEnabled = false; chatDescription->fullscreen = false; [viewDescriptions setObject:chatDescription forKey:[NSNumber numberWithInt: PhoneView_Chat]]; + + // + // IncomingCall View + // + UICompositeViewDescription *incomingCallDescription = [UICompositeViewDescription alloc]; + incomingCallDescription->content = @"FirstLoginViewController"; + incomingCallDescription->tabBar = nil; + incomingCallDescription->tabBarEnabled = false; + incomingCallDescription->stateBar = nil; + incomingCallDescription->stateBarEnabled = false; + incomingCallDescription->fullscreen = false; + [viewDescriptions setObject:incomingCallDescription forKey:[NSNumber numberWithInt: PhoneView_FirstLoginView]]; // Set observers [[NSNotificationCenter defaultCenter] addObserver:self @@ -208,12 +208,16 @@ name:UIDeviceBatteryLevelDidChangeNotification object:nil]; } - + - (void)viewDidUnload { + [super viewDidUnload]; [[NSNotificationCenter defaultCenter] removeObserver:self]; + + // Avoid IOS 4 bug + self->loadCount--; } -- (void)registrationUpdate: (NSNotification*) notif { +- (void)registrationUpdate:(NSNotification*)notif { LinphoneRegistrationState state = [[notif.userInfo objectForKey: @"state"] intValue]; LinphoneProxyConfig *cfg = [[notif.userInfo objectForKey: @"cfg"] pointerValue]; // Show error @@ -236,7 +240,7 @@ message:lErrorMessage delegate:nil cancelButtonTitle:NSLocalizedString(@"Continue",nil) - otherButtonTitles:nil ,nil]; + otherButtonTitles:nil,nil]; [error show]; [error release]; } @@ -245,7 +249,7 @@ } } -- (void)callUpdate:(NSNotification*) notif { +- (void)callUpdate:(NSNotification*)notif { LinphoneCall *call = [[notif.userInfo objectForKey: @"call"] pointerValue]; LinphoneCallState state = [[notif.userInfo objectForKey: @"state"] intValue]; NSString *message = [notif.userInfo objectForKey: @"message"]; @@ -286,7 +290,7 @@ } case LinphoneCallEnd: { - [self dismissIncomingCall]; + [self dismissIncomingCall:call]; if (canHideInCallView) { if ([[LinphoneManager instance] currentView] != PhoneView_Dialer) { // Go to dialer view @@ -348,30 +352,18 @@ [error release]; } -- (void)dismissIncomingCall { +- (void)dismissIncomingCall:(LinphoneCall*)call { //cancel local notification, just in case if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] - && [UIApplication sharedApplication].applicationState == UIApplicationStateBackground ) { + && [UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { // cancel local notif if needed [[UIApplication sharedApplication] cancelAllLocalNotifications]; - } else { - if (incomingCallActionSheet) { - [incomingCallActionSheet dismissWithClickedButtonIndex:1 animated:true]; - incomingCallActionSheet = nil; - } } - - //TODO - /* - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstlogindone_preference" ] == true) { - //first login case, dismmis first login view - [self dismissModalViewControllerAnimated:true]; - }; */ } - (void)displayIncomingCall:(LinphoneCall*) call{ -#if 0 + const char* userNameChars=linphone_address_get_username(linphone_call_get_remote_address(call)); NSString* userName = userNameChars?[[[NSString alloc] initWithUTF8String:userNameChars] autorelease]:NSLocalizedString(@"Unknown",nil); const char* displayNameChars = linphone_address_get_display_name(linphone_call_get_remote_address(call)); @@ -394,37 +386,14 @@ [[UIApplication sharedApplication] presentLocalNotificationNow:notif]; } - } else { - CallDelegate* cd = [[CallDelegate alloc] init]; - cd.eventType = CD_NEW_CALL; - cd.delegate = self; - cd.call = call; - - incomingCallActionSheet = [[UIActionSheet alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedString(@" %@ is calling you",nil),[displayName length]>0?displayName:userName] - delegate:cd - cancelButtonTitle:nil - destructiveButtonTitle:NSLocalizedString(@"Answer",nil) - otherButtonTitles:NSLocalizedString(@"Decline",nil),nil]; - - incomingCallActionSheet.actionSheetStyle = UIActionSheetStyleDefault; - //TODO - /*if ([LinphoneManager runningOnIpad]) { - if (self.modalViewController != nil) - [incomingCallActionSheet showInView:[self.modalViewController view]]; - else - [incomingCallActionSheet showInView:self.parentViewController.view]; - } else */{ - [incomingCallActionSheet showInView: self.view]; - } - [incomingCallActionSheet release]; + } else { + IncomingCallViewController *controller = [[IncomingCallViewController alloc] init]; + [controller update:call]; + [self addModalViewController:controller]; } -#endif - //UICompositeViewController *controller = [[UICompositeViewController alloc] initWithNibName:@"UICompositeViewController" bundle:[NSBundle mainBundle]]; - [modalViewController changeView:[viewDescriptions objectForKey:[NSNumber numberWithInt:PhoneView_IncomingCall]]]; - [self presentModalViewController:modalViewController animated:false]; } -- (void)batteryLevelChanged: (NSNotification*) notif { +- (void)batteryLevelChanged:(NSNotification*)notif { LinphoneCall* call = linphone_core_get_current_call([LinphoneManager getLc]); if (!call || !linphone_call_params_video_enabled(linphone_call_get_current_params(call))) return; @@ -460,28 +429,17 @@ - (void)actionSheet:(UIActionSheet *)actionSheet ofType:(enum CallDelegateType)type clickedButtonAtIndex:(NSInteger)buttonIndex withUserDatas:(void *)datas { - switch(type) { - case CD_NEW_CALL: - { - LinphoneCall* call = (LinphoneCall*)datas; - if (buttonIndex == actionSheet.destructiveButtonIndex) { - linphone_core_accept_call([LinphoneManager getLc], call); - } else { - linphone_core_terminate_call([LinphoneManager getLc], call); - } - incomingCallActionSheet = nil; - break; - } case CD_STOP_VIDEO_ON_LOW_BATTERY: { LinphoneCall* call = (LinphoneCall*)datas; LinphoneCallParams* paramsCopy = linphone_call_params_copy(linphone_call_get_current_params(call)); - if ([batteryActionSheet destructiveButtonIndex] == buttonIndex) { + if (buttonIndex == [batteryActionSheet destructiveButtonIndex]) { // stop video linphone_call_params_enable_video(paramsCopy, FALSE); linphone_core_update_call([LinphoneManager getLc], call, paramsCopy); } + batteryActionSheet = nil; break; } default: @@ -489,12 +447,50 @@ } } +- (void)modalViewDismiss:(UIModalViewController*)controller value:(int)value { + [self removeModalViewController:controller]; +} + +- (void)addModalViewController:(UIModalViewController*)controller { + [controller setModalDelegate:self]; + [modalControllers insertObject:controller atIndex:0]; + + CATransition* trans = [CATransition animation]; + [trans setType:kCATransitionFade]; + [trans setDuration:0.35]; + [trans setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; + [trans setSubtype:kCATransitionFromRight]; + [[self view].layer addAnimation:trans forKey:@"Appear"]; + + [[self view] addSubview:[controller view]]; + [[self view] bringSubviewToFront:[controller view]]; +} + +- (void)removeModalViewController:(UIModalViewController*)controller { + [controller setModalDelegate:nil]; + [modalControllers removeObject:controller]; + + CATransition* trans = [CATransition animation]; + [trans setType:kCATransitionFade]; + [trans setDuration:0.35]; + [trans setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; + [trans setSubtype:kCATransitionFromRight]; + [[self view].layer addAnimation:trans forKey:@"Disappear"]; + + [[controller view] removeFromSuperview]; +} + - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; + [mainViewController release]; + [viewDescriptions removeAllObjects]; [viewDescriptions release]; + [modalControllers removeAllObjects]; + [modalControllers release]; + [super dealloc]; } diff --git a/Classes/PhoneMainView.xib b/Classes/PhoneMainView.xib index 0976956ee..c88d806f2 100644 --- a/Classes/PhoneMainView.xib +++ b/Classes/PhoneMainView.xib @@ -41,7 +41,6 @@ {320, 460} - _NS:9 3 @@ -125,7 +124,6 @@ {{192, 0}, {128, 72}} - _NS:9 NO @@ -208,17 +206,6 @@ IBCocoaTouchFramework NO - - NO - UICompositeViewController - - - 1 - 1 - - IBCocoaTouchFramework - NO - @@ -239,14 +226,6 @@ 209 - - - modalViewController - - - - 211 - @@ -322,12 +301,6 @@ mainViewController - - 210 - - - modalViewController - @@ -349,8 +322,6 @@ 169.IBPluginDependency 208.CustomClassName 208.IBPluginDependency - 210.CustomClassName - 210.IBPluginDependency YES @@ -369,8 +340,6 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin UICompositeViewController com.apple.InterfaceBuilder.IBCocoaTouchPlugin - UICompositeViewController - com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -394,35 +363,14 @@ PhoneMainView UIViewController - YES - - YES - mainViewController - modalViewController - - - YES - UICompositeViewController - UICompositeViewController - + mainViewController + UICompositeViewController - YES - - YES - mainViewController - modalViewController - - - YES - - mainViewController - UICompositeViewController - - - modalViewController - UICompositeViewController - + mainViewController + + mainViewController + UICompositeViewController diff --git a/Classes/SettingsViewController.m b/Classes/SettingsViewController.m index 099c208c1..5411037f3 100644 --- a/Classes/SettingsViewController.m +++ b/Classes/SettingsViewController.m @@ -30,7 +30,7 @@ } - (void)viewDidLoad { - settingsController.delegate = [LinphoneManager instance]; + settingsController.delegate = self; settingsController.settingsReaderDelegate = self; settingsController.settingsStore=[[LinphoneManager instance] settingsStore]; settingsController.showCreditsFooter = FALSE; @@ -71,6 +71,10 @@ } // hide setting if bg mode not supported return nil; + } + if ([identifier isEqualToString:@"enable_first_login_view_preference"]) { + // hide first login view preference + return nil; } if (![LinphoneManager codecIsSupported:identifier]) return Nil; @@ -78,8 +82,34 @@ } - (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController *)sender { - ms_message("Synchronize settings"); - [[[LinphoneManager instance] settingsStore] synchronize]; +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) { + [settingsController viewWillDisappear:NO]; + } +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) { + [settingsController viewWillAppear:NO]; + } +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) { + [settingsController viewDidAppear:NO]; + } +} + +- (void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; + if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) { + [settingsController viewDidDisappear:NO]; + } } @end diff --git a/Resources/ombre-cotes-avatar.png b/Resources/ombre-cotes-avatar.png new file mode 100644 index 000000000..7a8aac483 Binary files /dev/null and b/Resources/ombre-cotes-avatar.png differ diff --git a/Settings/InAppSettings.bundle/Advanced.plist b/Settings/InAppSettings.bundle/Advanced.plist index bfe884eb2..fa4638291 100644 --- a/Settings/InAppSettings.bundle/Advanced.plist +++ b/Settings/InAppSettings.bundle/Advanced.plist @@ -130,6 +130,16 @@ Type PSToggleSwitchSpecifier + + DefaultValue + + Key + enable_first_login_view_preference + Title + First login view + Type + PSToggleSwitchSpecifier + diff --git a/Settings/InAppSettings.bundle/Root.plist b/Settings/InAppSettings.bundle/Root.plist index f2aa11c6c..ae95540e2 100644 --- a/Settings/InAppSettings.bundle/Root.plist +++ b/Settings/InAppSettings.bundle/Root.plist @@ -110,7 +110,7 @@ File - audio + Audio Title Audio Codecs Type @@ -118,7 +118,7 @@ File - video + Video Title Video Type diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 21854c92d..8fb12ee79 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -444,6 +444,10 @@ D3F26BFA15986DAD005F9CAB /* ok-edit-list-history-over.png in Resources */ = {isa = PBXBuildFile; fileRef = D3F26BF615986DAD005F9CAB /* ok-edit-list-history-over.png */; }; D3F26BFC15987083005F9CAB /* champ-titre-incoming.png in Resources */ = {isa = PBXBuildFile; fileRef = D3F26BFB15987083005F9CAB /* champ-titre-incoming.png */; }; D3F26BFD15987083005F9CAB /* champ-titre-incoming.png in Resources */ = {isa = PBXBuildFile; fileRef = D3F26BFB15987083005F9CAB /* champ-titre-incoming.png */; }; + D3F34F301599B008005BE94F /* ombre-cotes-avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = D3F34F2F1599B008005BE94F /* ombre-cotes-avatar.png */; }; + D3F34F311599B008005BE94F /* ombre-cotes-avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = D3F34F2F1599B008005BE94F /* ombre-cotes-avatar.png */; }; + D3F34F351599C354005BE94F /* UIModalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D3F34F341599C354005BE94F /* UIModalViewController.m */; }; + D3F34F361599C354005BE94F /* UIModalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D3F34F341599C354005BE94F /* UIModalViewController.m */; }; D3F83EEC1582021700336684 /* InCallViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D3F83EEA1582021700336684 /* InCallViewController.m */; }; D3F83EED1582021700336684 /* InCallViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D3F83EEA1582021700336684 /* InCallViewController.m */; }; D3F83EEE1582021700336684 /* InCallViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D3F83EEB1582021700336684 /* InCallViewController.xib */; }; @@ -1063,6 +1067,9 @@ D3F26BF515986DAD005F9CAB /* ok-edit-list-history-actif.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "ok-edit-list-history-actif.png"; path = "Resources/ok-edit-list-history-actif.png"; sourceTree = ""; }; D3F26BF615986DAD005F9CAB /* ok-edit-list-history-over.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "ok-edit-list-history-over.png"; path = "Resources/ok-edit-list-history-over.png"; sourceTree = ""; }; D3F26BFB15987083005F9CAB /* champ-titre-incoming.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "champ-titre-incoming.png"; path = "Resources/champ-titre-incoming.png"; sourceTree = ""; }; + D3F34F2F1599B008005BE94F /* ombre-cotes-avatar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "ombre-cotes-avatar.png"; path = "Resources/ombre-cotes-avatar.png"; sourceTree = ""; }; + D3F34F331599C354005BE94F /* UIModalViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIModalViewController.h; sourceTree = ""; }; + D3F34F341599C354005BE94F /* UIModalViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIModalViewController.m; sourceTree = ""; }; D3F83EE91582021700336684 /* InCallViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InCallViewController.h; sourceTree = ""; }; D3F83EEA1582021700336684 /* InCallViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InCallViewController.m; sourceTree = ""; }; D3F83EEB1582021700336684 /* InCallViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InCallViewController.xib; sourceTree = ""; }; @@ -1545,6 +1552,8 @@ D3ED3E861586291C006C0DE4 /* UIMainBar.xib */, 2214EBF112F86360002A5394 /* UIMicroButton.h */, 2214EBF212F86360002A5394 /* UIMicroButton.m */, + D3F34F331599C354005BE94F /* UIModalViewController.h */, + D3F34F341599C354005BE94F /* UIModalViewController.m */, D36FB2D31589EF7C0036F6F2 /* UIPauseButton.h */, D36FB2D41589EF7C0036F6F2 /* UIPauseButton.m */, 22968A5D12F875C600588287 /* UISpeakerButton.h */, @@ -1815,6 +1824,7 @@ D3F26BF615986DAD005F9CAB /* ok-edit-list-history-over.png */, 2242E312125235120061DDCE /* oldphone-mono-30s.caf */, 2237D4081084D7A9001383EE /* oldphone-mono.wav */, + D3F34F2F1599B008005BE94F /* ombre-cotes-avatar.png */, D3F83EF8158205A100336684 /* pause-actif.png */, D36C43ED158F61EA0048BA40 /* pause-champ-numero-actif.png */, D36C43EE158F61EA0048BA40 /* pause-champ-numero-over.png */, @@ -2227,6 +2237,7 @@ D31B4B23159876C0002E6C72 /* UICompositeViewController.xib in Resources */, D31B4B281598A390002E6C72 /* avatar-inconnu.png in Resources */, D31B4B2A1598A390002E6C72 /* avatar-small.png in Resources */, + D3F34F301599B008005BE94F /* ombre-cotes-avatar.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2399,6 +2410,7 @@ D31B4B24159876C0002E6C72 /* UICompositeViewController.xib in Resources */, D31B4B291598A390002E6C72 /* avatar-inconnu.png in Resources */, D31B4B2B1598A390002E6C72 /* avatar-small.png in Resources */, + D3F34F311599B008005BE94F /* ombre-cotes-avatar.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2471,6 +2483,7 @@ D3F26BEC159869A6005F9CAB /* AbstractCall.m in Sources */, D3F26BF115986B73005F9CAB /* IncomingCallViewController.m in Sources */, D31B4B21159876C0002E6C72 /* UICompositeViewController.m in Sources */, + D3F34F351599C354005BE94F /* UIModalViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2540,6 +2553,7 @@ D3F26BED159869A6005F9CAB /* AbstractCall.m in Sources */, D3F26BF215986B73005F9CAB /* IncomingCallViewController.m in Sources */, D31B4B22159876C0002E6C72 /* UICompositeViewController.m in Sources */, + D3F34F361599C354005BE94F /* UIModalViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/linphonerc b/linphonerc index 9a2ba91f6..8eede1cd0 100644 --- a/linphonerc +++ b/linphonerc @@ -42,4 +42,3 @@ show_local=0 enabled=1 size=qvga display_filter_auto_rotate=1 -