diff --git a/Classes/CallHistoryTableViewController.m b/Classes/CallHistoryTableViewController.m index a1dd4158b..469e338a3 100644 --- a/Classes/CallHistoryTableViewController.m +++ b/Classes/CallHistoryTableViewController.m @@ -184,7 +184,7 @@ } else { phoneNumber = [[NSString alloc] initWithCString:linphone_address_as_string_uri_only(partyToCall) encoding:[NSString defaultCStringEncoding]]; } - [[LinphoneManager instance].uiController displayDialerFromUI:self + [[LinphoneManager instance].callDelegate displayDialerFromUI:self forUser:phoneNumber withDisplayName:[[NSString alloc] initWithCString:displayName encoding:[NSString defaultCStringEncoding]]]; diff --git a/Classes/ContactPickerDelegate.m b/Classes/ContactPickerDelegate.m index a7541bf9d..03aa06502 100644 --- a/Classes/ContactPickerDelegate.m +++ b/Classes/ContactPickerDelegate.m @@ -36,14 +36,14 @@ CFTypeRef multiValue = ABRecordCopyValue(person, property); CFIndex valueIdx = ABMultiValueGetIndexForIdentifier(multiValue,identifier); NSString *phoneNumber = (NSString *)ABMultiValueCopyValueAtIndex(multiValue, valueIdx); - [[LinphoneManager instance].uiController displayDialerFromUI:nil + [[LinphoneManager instance].callDelegate displayDialerFromUI:nil forUser:phoneNumber withDisplayName:(NSString*)ABRecordCopyCompositeName(person)]; return false; } - (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker { - [[LinphoneManager instance].uiController displayDialerFromUI:nil + [[LinphoneManager instance].callDelegate displayDialerFromUI:nil forUser:nil withDisplayName:@""]; } diff --git a/Classes/FirstLoginViewController.h b/Classes/FirstLoginViewController.h new file mode 100644 index 000000000..97b27cf68 --- /dev/null +++ b/Classes/FirstLoginViewController.h @@ -0,0 +1,40 @@ +/* IncallViewController.h + * + * Copyright (C) 2009 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 Library 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 +#import "LinphoneAppDelegate.h" +#import "LinphoneUIDelegates.h" + + +@interface FirstLoginViewController : UIViewController { + UIButton* ok; + UIButton* site; + UITextField* username; + UIView* activityIndicator; + + +} +-(void) doOk:(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; +@end diff --git a/Classes/FirstLoginViewController.m b/Classes/FirstLoginViewController.m new file mode 100644 index 000000000..e1ca0a50a --- /dev/null +++ b/Classes/FirstLoginViewController.m @@ -0,0 +1,114 @@ +/* IncallViewController.h + * + * Copyright (C) 2009 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 Library 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 "FirstLoginViewController.h" +#import "LinphoneManager.h" + +@implementation FirstLoginViewController + +@synthesize ok; +@synthesize username; +@synthesize passwd; +@synthesize activityIndicator; +@synthesize site; + + + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + //[username setText:[[NSUserDefaults standardUserDefaults] stringForKey:@"username_preference"]]; + //[passwd setText:[[NSUserDefaults standardUserDefaults] stringForKey:@"password_preference"]]; +} + + + +- (void)dealloc { + [super dealloc]; + [ok dealloc]; + [site dealloc]; + [username dealloc]; + [activityIndicator dealloc]; +} + + + +-(void) doOk:(id)sender { + if (sender == site) { + NSURL *url = [NSURL URLWithString:@"http://www.linphone.org"]; + [[UIApplication sharedApplication] openURL:url]; + return; + } + NSString* errorMessage=nil; + if ([username.text length]==0 ) { + errorMessage=NSLocalizedString(@"Enter your username",nil); + } else if ([passwd.text length]==0 ) { + errorMessage=NSLocalizedString(@"Enter your password",nil); + } + + if (errorMessage != nil) { + UIAlertView* error=nil; + error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Alert",nil) + message:errorMessage + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Continue",nil) + otherButtonTitles:nil]; + [error show]; + } else { + [[NSUserDefaults standardUserDefaults] setObject:username.text forKey:@"username_preference"]; + [[NSUserDefaults standardUserDefaults] setObject:passwd.text forKey:@"password_preference"]; + [self.activityIndicator setHidden:false]; + }; + + +} +-(void) displayRegisteredFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName onDomain:(NSString*)domain { + [[NSUserDefaults standardUserDefaults] setBool:true forKey:@"enable_first_login_view_preference"]; + [self.parentViewController dismissModalViewControllerAnimated:true]; + [self.activityIndicator setHidden:true]; + [[LinphoneManager instance] setRegistrationDelegate:nil]; +} +-(void) displayRegisteringFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName onDomain:(NSString*)domain { + [self.activityIndicator setHidden:false]; +} +-(void) displayRegistrationFailedFromUI:(UIViewController*) viewCtrl forUser:(NSString*) user withDisplayName:(NSString*) displayName onDomain:(NSString*)domain forReason:(NSString*) reason { + [self.activityIndicator 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]; + +} +-(void) displayNotRegisteredFromUI:(UIViewController*) viewCtrl { + [self.activityIndicator setHidden:true]; +} + + +- (BOOL)textFieldShouldReturn:(UITextField *)theTextField { + // When the user presses return, take focus away from the text field so that the keyboard is dismissed. + [theTextField resignFirstResponder]; + return YES; +} + + +@end diff --git a/Classes/FirstLoginViewController.xib b/Classes/FirstLoginViewController.xib new file mode 100644 index 000000000..2c8342a90 --- /dev/null +++ b/Classes/FirstLoginViewController.xib @@ -0,0 +1,817 @@ + + + + 784 + 10J567 + 823 + 1038.35 + 462.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 132 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + + 292 + + YES + + + 292 + {{0, -20}, {360, 480}} + + NO + NO + 9 + NO + IBCocoaTouchFramework + + + + 292 + {{25, 319}, {184, 37}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + Helvetica-Bold + 15 + 16 + + http://www.linphone.org + + 3 + MQA + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + 3 + MC41AA + + + + + 292 + {{105, 75}, {197, 31}} + + NO + NO + IBCocoaTouchFramework + 0 + + 3 + + 3 + MAA + + 2 + + + YES + YES + 17 + + 1 + YES + IBCocoaTouchFramework + + + + + 292 + {{9, 80}, {100, 21}} + + NO + YES + NO + IBCocoaTouchFramework + Password* + + 1 + MCAwIDAAA + + + 1 + NO + 10 + + + + 292 + {{105, 34}, {197, 31}} + + NO + NO + IBCocoaTouchFramework + 0 + + 3 + + 3 + MAA + + + YES + 17 + + 1 + IBCocoaTouchFramework + + + + + 292 + {{9, 40}, {100, 21}} + + + 3 + MCAwAA + + NO + YES + NO + IBCocoaTouchFramework + Username* + + + 1 + NO + 10 + + + + 292 + {{105, 154}, {195, 37}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + login + + + 1 + MC4xOTYwNzg0MzE0IDAuMzA5ODAzOTIxNiAwLjUyMTU2ODYyNzUAA + + + + + + -2147483356 + + YES + + + 292 + {{142, 211}, {37, 37}} + + NO + NO + NO + IBCocoaTouchFramework + NO + YES + 0 + + + {320, 460} + + + 3 + MQA + + + NO + IBCocoaTouchFramework + + + {320, 460} + + + 3 + MQA + + + + IBCocoaTouchFramework + + + + 1 + + IBCocoaTouchFramework + NO + + + + + YES + + + view + + + + 3 + + + + passwd + + + + 15 + + + + delegate + + + + 17 + + + + doOk: + + + 7 + + 20 + + + + activityIndicator + + + + 33 + + + + site + + + + 36 + + + + doOk: + + + 7 + + 37 + + + + username + + + + 38 + + + + delegate + + + + 39 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 4 + + + YES + + + + + + 1 + + + YES + + + + + + + + + + + + + 12 + + + + + 6 + + + username + + + 35 + + + site + + + 8 + + + passwd + + + 9 + + + + + 7 + + + + + 5 + + + + + 31 + + + YES + + + + wait + + + 32 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 1.IBUserGuides + 1.IBViewBoundsToFrameTransform + 12.IBPluginDependency + 12.IBViewBoundsToFrameTransform + 31.IBEditorWindowLastContentRect + 31.IBPluginDependency + 31.IBViewBoundsToFrameTransform + 32.IBPluginDependency + 35.IBPluginDependency + 4.IBEditorWindowLastContentRect + 4.IBPluginDependency + 4.IBViewEditorWindowController.showingBoundsRectangles + 5.IBPluginDependency + 6.IBPluginDependency + 7.IBPluginDependency + 8.IBPluginDependency + 9.IBPluginDependency + + + YES + FirstLoginViewController + UIResponder + {{444, 412}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + YES + + + 105 + 0 + + + + P4AAAL+AAAAAAAAAw+UAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABDUgAAw7EAAA + + {{193, 650}, {320, 460}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAAAAAAAAw+UAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + {{85, 76}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 53 + + + + YES + + FirstLoginViewController + UIViewController + + doOk: + id + + + doOk: + + doOk: + id + + + + YES + + YES + activityIndicator + ok + passwd + site + username + + + YES + UIView + UIButton + UITextField + UIButton + UITextField + + + + YES + + YES + activityIndicator + ok + passwd + site + username + + + YES + + activityIndicator + UIView + + + ok + UIButton + + + passwd + UITextField + + + site + UIButton + + + username + UITextField + + + + + IBProjectSource + Classes/FirstLoginViewController.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIActivityIndicatorView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIActivityIndicatorView.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UIImageView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIImageView.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UIResponder + NSObject + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UITextField + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIPrintFormatter.h + + + + UIView + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + ../linphone.xcodeproj + 3 + 132 + + diff --git a/Classes/LinphoneUI/LinphoneManager.h b/Classes/LinphoneUI/LinphoneManager.h index f7ccd3309..547621f07 100644 --- a/Classes/LinphoneUI/LinphoneManager.h +++ b/Classes/LinphoneUI/LinphoneManager.h @@ -21,7 +21,7 @@ #import #include "linphonecore.h" #import "LogView.h" -#import "LinphoneUIControler.h" +#import "LinphoneUIDelegates.h" @interface LinphoneManager : NSObject { @private @@ -31,7 +31,9 @@ NSTimer* mIterateTimer; id mLogView; bool isbackgroundModeEnabled; - id uiController; + id callDelegate; + id registrationDelegate; + UIViewController* mCurrentViewController; } @@ -47,5 +49,6 @@ -(void) becomeActive; -(void) kickOffNetworkConnection; -@property (nonatomic, retain) id uiController; +@property (nonatomic, retain) id callDelegate; +@property (nonatomic, retain) id registrationDelegate; @end diff --git a/Classes/LinphoneUI/LinphoneManager.m b/Classes/LinphoneUI/LinphoneManager.m index 2812d3730..e24aade25 100644 --- a/Classes/LinphoneUI/LinphoneManager.m +++ b/Classes/LinphoneUI/LinphoneManager.m @@ -33,7 +33,8 @@ extern void libmsilbc_init(); @implementation LinphoneManager -@synthesize uiController; +@synthesize callDelegate; +@synthesize registrationDelegate; +(LinphoneManager*) instance { if (theLinphoneManager==nil) { @@ -50,19 +51,19 @@ extern void libmsilbc_init(); switch (new_state) { case LinphoneCallIncomingReceived: - [uiController displayIncomingCallNotigicationFromUI:mCurrentViewController + [callDelegate displayIncomingCallNotigicationFromUI:mCurrentViewController forUser:lUserName withDisplayName:lDisplayName]; break; case LinphoneCallOutgoingInit: - [uiController displayCallInProgressFromUI:mCurrentViewController + [callDelegate displayCallInProgressFromUI:mCurrentViewController forUser:lUserName withDisplayName:lDisplayName]; break; case LinphoneCallConnected: - [uiController displayIncallFromUI:mCurrentViewController + [callDelegate displayIncallFromUI:mCurrentViewController forUser:lUserName withDisplayName:lDisplayName]; break; @@ -89,13 +90,13 @@ extern void libmsilbc_init(); cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; [error show]; - [uiController displayDialerFromUI:mCurrentViewController + [callDelegate displayDialerFromUI:mCurrentViewController forUser:@"" withDisplayName:@""]; break; } case LinphoneCallEnd: - [uiController displayDialerFromUI:mCurrentViewController + [callDelegate displayDialerFromUI:mCurrentViewController forUser:@"" withDisplayName:@""]; break; @@ -116,7 +117,7 @@ extern void libmsilbc_init(); [mLogView addLog:log]; } -(void)displayStatus:(NSString*) message { - [uiController displayStatus:message]; + [callDelegate displayStatus:message]; } //generic log handler for debug version static void linphone_iphone_log_handler(int lev, const char *fmt, va_list args){ @@ -162,16 +163,40 @@ static void linphone_iphone_call_state(LinphoneCore *lc, LinphoneCall* call, Lin } -static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyConfig* cfg, LinphoneRegistrationState state,const char* message) { - if (state == LinphoneRegistrationFailed ) { +-(void) onRegister:(LinphoneCore *)lc cfg:(LinphoneProxyConfig*) cfg state:(LinphoneRegistrationState) state message:(const char*) message { + LinphoneAddress* lAddress = linphone_address_new(linphone_proxy_config_get_identity(cfg)); + NSString* lUserName = linphone_address_get_username(lAddress)? [[NSString alloc] initWithCString:linphone_address_get_username(lAddress) ]:@""; + NSString* lDisplayName = linphone_address_get_display_name(lAddress)? [[NSString alloc] initWithCString:linphone_address_get_display_name(lAddress) ]:@""; + NSString* lDomain = [[NSString alloc] initWithCString:linphone_address_get_domain(lAddress)]; + + if (state == LinphoneRegistrationOk) { + [[(LinphoneManager*)linphone_core_get_user_data(lc) registrationDelegate] displayRegisteredFromUI:nil + forUser:lUserName + withDisplayName:lDisplayName + onDomain:lDomain ]; + } else if (state == LinphoneRegistrationProgress) { + [registrationDelegate displayRegisteringFromUI:mCurrentViewController + forUser:lUserName + withDisplayName:lDisplayName + onDomain:lDomain ]; + + } else if (state == LinphoneRegistrationCleared || state == LinphoneRegistrationNone) { + [registrationDelegate displayNotRegisteredFromUI:mCurrentViewController]; + } else if (state == LinphoneRegistrationFailed ) { NSString* lErrorMessage; if (linphone_proxy_config_get_error(cfg) == LinphoneReasonBadCredentials) { lErrorMessage = @"Bad credentials, check your account settings"; } else if (linphone_proxy_config_get_error(cfg) == LinphoneReasonNoResponse) { lErrorMessage = @"SIP server unreachable"; } - if (lErrorMessage != nil) { - + [registrationDelegate displayRegistrationFailedFromUI:mCurrentViewController + forUser:lUserName + withDisplayName:lDisplayName + onDomain:lDomain + forReason:lErrorMessage]; + + if (lErrorMessage != nil && registrationDelegate==nil) { + //default behavior if no registration delegates UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Registration failure" message:lErrorMessage @@ -184,7 +209,9 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo } } - +static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyConfig* cfg, LinphoneRegistrationState state,const char* message) { + [(LinphoneManager*)linphone_core_get_user_data(lc) onRegister:lc cfg:cfg state:state message:message]; +} static LinphoneCoreVTable linphonec_vtable = { .show =NULL, .call_state_changed =(LinphoneCallStateCb)linphone_iphone_call_state, @@ -404,8 +431,12 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach isbackgroundModeEnabled=false; } - - +} +// no proxy configured alert +- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { + if (buttonIndex == 1) { + [[NSUserDefaults standardUserDefaults] setBool:true forKey:@"check_config_disable_preference"]; + } } -(void) destroyLibLinphone { [mIterateTimer invalidate]; diff --git a/Classes/LinphoneUI/LinphoneUIControler.h b/Classes/LinphoneUI/LinphoneUIDelegates.h similarity index 71% rename from Classes/LinphoneUI/LinphoneUIControler.h rename to Classes/LinphoneUI/LinphoneUIDelegates.h index aa0b632c0..425de9b46 100644 --- a/Classes/LinphoneUI/LinphoneUIControler.h +++ b/Classes/LinphoneUI/LinphoneUIDelegates.h @@ -19,7 +19,7 @@ #import -@protocol LinphoneUIControler +@protocol LinphoneUICallDelegate // UI changes -(void) displayDialerFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName; -(void) displayCallInProgressFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName; @@ -29,3 +29,12 @@ -(void) displayStatus:(NSString*) message; @end + +@protocol LinphoneUIRegistrationDelegate +// UI changes for registration +-(void) displayRegisteredFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName onDomain:(NSString*)domain ; +-(void) displayRegisteringFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName onDomain:(NSString*)domain ; +-(void) displayRegistrationFailedFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName onDomain:(NSString*)domain forReason:(NSString*) reason; +-(void) displayNotRegisteredFromUI:(UIViewController*) viewCtrl; +@end + diff --git a/Classes/LinphoneUI/UILinphone.h b/Classes/LinphoneUI/UILinphone.h index 3c74358d7..de158faad 100644 --- a/Classes/LinphoneUI/UILinphone.h +++ b/Classes/LinphoneUI/UILinphone.h @@ -24,4 +24,4 @@ #import "UIMuteButton.h" #import "UISpeakerButton.h" #import "UIDuration.h" -#import "LinphoneUIControler.h" +#import "LinphoneUIDelegates.h" diff --git a/Classes/PhoneViewController.h b/Classes/PhoneViewController.h index a46267089..84e77b4c0 100644 --- a/Classes/PhoneViewController.h +++ b/Classes/PhoneViewController.h @@ -23,8 +23,9 @@ @class IncallViewController; +@class FirstLoginViewController; -@interface PhoneViewController : UIViewController { +@interface PhoneViewController : UIViewController { @private //UI definition @@ -62,7 +63,7 @@ UITabBarController* myTabBarController; IncallViewController *myIncallViewController; UIActionSheet *mIncomingCallActionSheet; - + FirstLoginViewController* myFirstLoginViewController; } @property (nonatomic, retain) IBOutlet UITextField* address; diff --git a/Classes/PhoneViewController.m b/Classes/PhoneViewController.m index 4a3b3a987..6794ab5fd 100644 --- a/Classes/PhoneViewController.m +++ b/Classes/PhoneViewController.m @@ -82,6 +82,12 @@ - (void)viewDidAppear:(BOOL)animated { [[UIApplication sharedApplication] setIdleTimerDisabled:true]; [mute reset]; + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"enable_first_login_view_preference"] == false) { + myFirstLoginViewController = [[FirstLoginViewController alloc] initWithNibName:@"FirstLoginViewController" + bundle:[NSBundle mainBundle]]; + [[LinphoneManager instance] setRegistrationDelegate:myFirstLoginViewController]; + [self presentModalViewController:myFirstLoginViewController animated:true]; + }; } - (void)viewDidDisappear:(BOOL)animated { @@ -92,6 +98,7 @@ // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; + mDisplayName = [UILabel alloc]; [zero initWithNumber:'0' addressField:address ]; [one initWithNumber:'1' addressField:address ]; @@ -109,6 +116,7 @@ [mute initWithOnImage:[UIImage imageNamed:@"mic_muted.png"] offImage:[UIImage imageNamed:@"mic_active.png"] ]; [speaker initWithOnImage:[UIImage imageNamed:@"Speaker-32-on.png"] offImage:[UIImage imageNamed:@"Speaker-32-off.png"] ]; + } @@ -169,7 +177,11 @@ [callDuration stop]; [peerLabel setText:@""]; - + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstlogindone_preference" + bundle:[NSBundle mainBundle]] == true) { + //first login case, dismmis first login view + [self dismissModalViewControllerAnimated:true]; + }; [myTabBarController setSelectedIndex:DIALER_TAB_INDEX]; } @@ -243,6 +255,10 @@ linphone_core_terminate_call ([LinphoneManager getLc],linphone_core_get_current_call([LinphoneManager getLc])); } mIncomingCallActionSheet = nil; +} +-(void) displayFirstLoginUI:(UIWindow *) window { + + } - (void)dealloc { [address dealloc]; diff --git a/Classes/linphoneAppDelegate.h b/Classes/linphoneAppDelegate.h index 583b73cbb..3824b46e0 100644 --- a/Classes/linphoneAppDelegate.h +++ b/Classes/linphoneAppDelegate.h @@ -31,6 +31,7 @@ @class PhoneViewController; @class CallHistoryTableViewController; + @interface linphoneAppDelegate : NSObject { UIWindow *window; IBOutlet UITabBarController* myTabBarController; @@ -38,6 +39,7 @@ IBOutlet PhoneViewController* myPhoneViewController; CallHistoryTableViewController* myCallHistoryTableViewController; ContactPickerDelegate* myContactPickerDelegate; + } @property (nonatomic, retain) IBOutlet UIWindow *window; diff --git a/Classes/linphoneAppDelegate.m b/Classes/linphoneAppDelegate.m index 7a053512c..fd05da6c5 100644 --- a/Classes/linphoneAppDelegate.m +++ b/Classes/linphoneAppDelegate.m @@ -83,11 +83,13 @@ [window makeKeyAndVisible]; - [[LinphoneManager instance] setUiController:myPhoneViewController]; + [[LinphoneManager instance] setCallDelegate:myPhoneViewController]; [[LinphoneManager instance] startLibLinphone]; [ [UIDevice currentDevice] setProximityMonitoringEnabled:true]; + + return YES; } @@ -102,15 +104,6 @@ } -// no proxy configured alert -- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { - if (buttonIndex == 1) { - [[NSUserDefaults standardUserDefaults] setBool:true forKey:@"check_config_disable_preference"]; - } -} - - - - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { linphone_core_accept_call([LinphoneManager getLc],linphone_core_get_current_call([LinphoneManager getLc])); } diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 4d4e49b9c..d64d90a0f 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -23,6 +23,8 @@ 2214EB8912F84EBB002A5394 /* UIHangUpButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 2214EB8812F84EBB002A5394 /* UIHangUpButton.m */; }; 2214EBDA12F8558F002A5394 /* UIToggleButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 2214EBD912F8558F002A5394 /* UIToggleButton.m */; }; 2214EBF312F86360002A5394 /* UIMuteButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 2214EBF212F86360002A5394 /* UIMuteButton.m */; }; + 2218A92512FBE1340088A667 /* FirstLoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2218A92312FBE1340088A667 /* FirstLoginViewController.m */; }; + 2218A92612FBE1340088A667 /* FirstLoginViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2218A92412FBE1340088A667 /* FirstLoginViewController.xib */; }; 22226C12118197C0000CA27B /* startcall-green.png in Resources */ = {isa = PBXBuildFile; fileRef = 22226C11118197C0000CA27B /* startcall-green.png */; }; 22226C14118197EC000CA27B /* stopcall-red.png in Resources */ = {isa = PBXBuildFile; fileRef = 22226C13118197EC000CA27B /* stopcall-red.png */; }; 22226C181181986A000CA27B /* contact-orange.png in Resources */ = {isa = PBXBuildFile; fileRef = 22226C161181986A000CA27B /* contact-orange.png */; }; @@ -228,8 +230,11 @@ 2214EBD912F8558F002A5394 /* UIToggleButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIToggleButton.m; sourceTree = ""; }; 2214EBF112F86360002A5394 /* UIMuteButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIMuteButton.h; sourceTree = ""; }; 2214EBF212F86360002A5394 /* UIMuteButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIMuteButton.m; sourceTree = ""; }; - 2218A5C412F9597B0088A667 /* LinphoneUIControler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinphoneUIControler.h; sourceTree = ""; }; + 2218A5C412F9597B0088A667 /* LinphoneUIDelegates.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinphoneUIDelegates.h; sourceTree = ""; }; 2218A5CE12F973450088A667 /* LogView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogView.h; sourceTree = ""; }; + 2218A92212FBE1340088A667 /* FirstLoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FirstLoginViewController.h; sourceTree = ""; }; + 2218A92312FBE1340088A667 /* FirstLoginViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FirstLoginViewController.m; sourceTree = ""; }; + 2218A92412FBE1340088A667 /* FirstLoginViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FirstLoginViewController.xib; sourceTree = ""; }; 22226C11118197C0000CA27B /* startcall-green.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "startcall-green.png"; path = "liblinphone-sdk/apple-darwin/share/pixmaps/linphone/startcall-green.png"; sourceTree = ""; }; 22226C13118197EC000CA27B /* stopcall-red.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "stopcall-red.png"; path = "liblinphone-sdk/apple-darwin/share/pixmaps/linphone/stopcall-red.png"; sourceTree = ""; }; 22226C161181986A000CA27B /* contact-orange.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "contact-orange.png"; path = "liblinphone-sdk/apple-darwin/share/pixmaps/linphone/contact-orange.png"; sourceTree = ""; }; @@ -334,6 +339,9 @@ isa = PBXGroup; children = ( 2214EB7012F84668002A5394 /* LinphoneUI */, + 2218A92212FBE1340088A667 /* FirstLoginViewController.h */, + 2218A92312FBE1340088A667 /* FirstLoginViewController.m */, + 2218A92412FBE1340088A667 /* FirstLoginViewController.xib */, 222A483112F7176F0075F07F /* IncallViewController.xib */, 222A483212F7176F0075F07F /* IncallViewController.m */, 222A483312F7176F0075F07F /* IncallViewController.h */, @@ -574,7 +582,7 @@ 22968A5E12F875C600588287 /* UISpeakerButton.m */, 22968A8612F87C2000588287 /* UIDuration.h */, 22968A8712F87C2000588287 /* UIDuration.m */, - 2218A5C412F9597B0088A667 /* LinphoneUIControler.h */, + 2218A5C412F9597B0088A667 /* LinphoneUIDelegates.h */, 2218A5CE12F973450088A667 /* LogView.h */, ); path = LinphoneUI; @@ -767,6 +775,7 @@ 2245F78A1201D38000C4179D /* MoreViewController.xib in Resources */, 2242E313125235120061DDCE /* oldphone-mono-30s.caf in Resources */, 222A483412F7176F0075F07F /* IncallViewController.xib in Resources */, + 2218A92612FBE1340088A667 /* FirstLoginViewController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -793,6 +802,7 @@ 2214EBF312F86360002A5394 /* UIMuteButton.m in Sources */, 22968A5F12F875C600588287 /* UISpeakerButton.m in Sources */, 22968A8812F87C2000588287 /* UIDuration.m in Sources */, + 2218A92512FBE1340088A667 /* FirstLoginViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };