From d0a0311b949b47e01b1dedc4f3065bea44801d34 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 3 Feb 2011 16:16:36 +0100 Subject: [PATCH] new UI architecture --- Classes/CallHistoryTableViewController.m | 18 +- Classes/ConsoleViewController.h | 30 +- Classes/ConsoleViewController.m | 2 +- Classes/ContactPickerDelegate.h | 5 +- Classes/ContactPickerDelegate.m | 14 +- Classes/GenericTabViewController.h | 5 - Classes/GenericTabViewController.m | 6 +- Classes/IncallViewController.h | 102 + Classes/IncallViewController.m | 243 +++ Classes/IncallViewController.xib | 1740 +++++++++++++++++ Classes/LinphoneUI/LinphoneManager.h | 51 + Classes/LinphoneUI/LinphoneManager.m | 611 ++++++ Classes/LinphoneUI/LinphoneUIControler.h | 31 + Classes/LinphoneUI/LogView.h | 27 + Classes/LinphoneUI/UICallButton.h | 30 + Classes/LinphoneUI/UICallButton.m | 88 + Classes/LinphoneUI/UIDigitButton.h | 30 + Classes/LinphoneUI/UIDigitButton.m | 81 + Classes/LinphoneUI/UIDuration.h | 33 + Classes/LinphoneUI/UIDuration.m | 66 + Classes/LinphoneUI/UIHangUpButton.h | 26 + Classes/LinphoneUI/UIHangUpButton.m | 58 + Classes/LinphoneUI/UILinphone.h | 27 + Classes/LinphoneUI/UIMuteButton.h | 28 + Classes/LinphoneUI/UIMuteButton.m | 56 + Classes/LinphoneUI/UISpeakerButton.h | 28 + Classes/LinphoneUI/UISpeakerButton.m | 64 + Classes/LinphoneUI/UIToggleButton.h | 41 + Classes/LinphoneUI/UIToggleButton.m | 73 + Classes/MoreViewController.m | 3 +- Classes/PhoneViewController.h | 78 +- Classes/PhoneViewController.m | 508 ++--- Classes/PhoneViewController.xib | 499 ++--- Classes/linphoneAppDelegate.h | 52 +- Classes/linphoneAppDelegate.m | 556 +----- linphone.xcodeproj/project.pbxproj | 82 +- .../liblinphone.xcodeproj/project.pbxproj | 2 + submodules/linphone | 2 +- 38 files changed, 3963 insertions(+), 1433 deletions(-) create mode 100644 Classes/IncallViewController.h create mode 100644 Classes/IncallViewController.m create mode 100644 Classes/IncallViewController.xib create mode 100644 Classes/LinphoneUI/LinphoneManager.h create mode 100644 Classes/LinphoneUI/LinphoneManager.m create mode 100644 Classes/LinphoneUI/LinphoneUIControler.h create mode 100644 Classes/LinphoneUI/LogView.h create mode 100644 Classes/LinphoneUI/UICallButton.h create mode 100644 Classes/LinphoneUI/UICallButton.m create mode 100644 Classes/LinphoneUI/UIDigitButton.h create mode 100644 Classes/LinphoneUI/UIDigitButton.m create mode 100644 Classes/LinphoneUI/UIDuration.h create mode 100644 Classes/LinphoneUI/UIDuration.m create mode 100644 Classes/LinphoneUI/UIHangUpButton.h create mode 100644 Classes/LinphoneUI/UIHangUpButton.m create mode 100644 Classes/LinphoneUI/UILinphone.h create mode 100644 Classes/LinphoneUI/UIMuteButton.h create mode 100644 Classes/LinphoneUI/UIMuteButton.m create mode 100644 Classes/LinphoneUI/UISpeakerButton.h create mode 100644 Classes/LinphoneUI/UISpeakerButton.m create mode 100644 Classes/LinphoneUI/UIToggleButton.h create mode 100644 Classes/LinphoneUI/UIToggleButton.m diff --git a/Classes/CallHistoryTableViewController.m b/Classes/CallHistoryTableViewController.m index 573b2f10d..a1dd4158b 100644 --- a/Classes/CallHistoryTableViewController.m +++ b/Classes/CallHistoryTableViewController.m @@ -18,6 +18,7 @@ */ #import "CallHistoryTableViewController.h" +#import "LinphoneManager.h" @implementation CallHistoryTableViewController @@ -88,7 +89,7 @@ -(void) doAction:(id)sender { - linphone_core_clear_call_logs(myLinphoneCore); + linphone_core_clear_call_logs([LinphoneManager getLc]); [self.tableView reloadData]; } @@ -101,7 +102,7 @@ // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - const MSList * logs = linphone_core_get_call_logs(myLinphoneCore); + const MSList * logs = linphone_core_get_call_logs([LinphoneManager getLc]); return ms_list_size(logs); } @@ -119,7 +120,7 @@ // Set up the cell... LinphoneAddress* partyToDisplay; - const MSList * logs = linphone_core_get_call_logs(myLinphoneCore); + const MSList * logs = linphone_core_get_call_logs([LinphoneManager getLc]); LinphoneCallLog* callLogs = ms_list_nth_data(logs, indexPath.row) ; NSString *path; @@ -159,7 +160,7 @@ // [anotherViewController release]; [tableView deselectRowAtIndexPath:indexPath animated:NO]; - const MSList * logs = linphone_core_get_call_logs(myLinphoneCore); + const MSList * logs = linphone_core_get_call_logs([LinphoneManager getLc]); LinphoneCallLog* callLogs = ms_list_nth_data(logs, indexPath.row) ; LinphoneAddress* partyToCall; if (callLogs->dir == LinphoneCallIncoming) { @@ -174,7 +175,7 @@ const char* domain = linphone_address_get_domain(partyToCall); LinphoneProxyConfig* proxyCfg; - linphone_core_get_default_proxy(myLinphoneCore,&proxyCfg); + linphone_core_get_default_proxy([LinphoneManager getLc],&proxyCfg); NSString* phoneNumber; @@ -183,11 +184,10 @@ } else { phoneNumber = [[NSString alloc] initWithCString:linphone_address_as_string_uri_only(partyToCall) encoding:[NSString defaultCStringEncoding]]; } - [self.phoneControllerDelegate - setPhoneNumber: phoneNumber - withDisplayName:[[NSString alloc] initWithCString:displayName encoding:[NSString defaultCStringEncoding]]]; + [[LinphoneManager instance].uiController displayDialerFromUI:self + forUser:phoneNumber + withDisplayName:[[NSString alloc] initWithCString:displayName encoding:[NSString defaultCStringEncoding]]]; - [self.linphoneDelegate selectDialerTab]; } diff --git a/Classes/ConsoleViewController.h b/Classes/ConsoleViewController.h index 090604fb0..882759b84 100644 --- a/Classes/ConsoleViewController.h +++ b/Classes/ConsoleViewController.h @@ -1,22 +1,26 @@ -/* - * ConsoleViewController.h +/* ConsoleViewController.h * - * Description: + * Copyright (C) 2010 Belledonne Comunications, Grenoble, France * - * - * Belledonne Communications (C) 2010 - * - * Copyright: See COPYING file that comes with this distribution - * - */ + * 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 "LogView.h" -@protocol LogView -+(void) addLog:(NSString*) log; - -@end @interface ConsoleViewController : UIViewController { UITextView* logs; diff --git a/Classes/ConsoleViewController.m b/Classes/ConsoleViewController.m index 722b08289..bf2cbb1e1 100644 --- a/Classes/ConsoleViewController.m +++ b/Classes/ConsoleViewController.m @@ -67,7 +67,7 @@ NSMutableString* MoreViewController_logs; } -+(void) addLog:(NSString*) log { +-(void) addLog:(NSString*) log { @synchronized(self) { if (!MoreViewController_logs) { MoreViewController_logs = [[NSMutableString alloc] init]; diff --git a/Classes/ContactPickerDelegate.h b/Classes/ContactPickerDelegate.h index 63708a46b..70cf7744d 100644 --- a/Classes/ContactPickerDelegate.h +++ b/Classes/ContactPickerDelegate.h @@ -23,11 +23,8 @@ @interface ContactPickerDelegate : NSObject { - id phoneControllerDelegate; - id linphoneDelegate; + } -@property (nonatomic, retain) id phoneControllerDelegate; -@property (nonatomic, retain) id linphoneDelegate; @end diff --git a/Classes/ContactPickerDelegate.m b/Classes/ContactPickerDelegate.m index d8de36897..a7541bf9d 100644 --- a/Classes/ContactPickerDelegate.m +++ b/Classes/ContactPickerDelegate.m @@ -17,11 +17,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #import "ContactPickerDelegate.h" - +#import "LinphoneManager.h" @implementation ContactPickerDelegate -@synthesize phoneControllerDelegate; -@synthesize linphoneDelegate; - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker @@ -38,14 +36,16 @@ CFTypeRef multiValue = ABRecordCopyValue(person, property); CFIndex valueIdx = ABMultiValueGetIndexForIdentifier(multiValue,identifier); NSString *phoneNumber = (NSString *)ABMultiValueCopyValueAtIndex(multiValue, valueIdx); - [phoneControllerDelegate setPhoneNumber:phoneNumber withDisplayName:(NSString*)ABRecordCopyCompositeName(person)]; - - [linphoneDelegate selectDialerTab]; + [[LinphoneManager instance].uiController displayDialerFromUI:nil + forUser:phoneNumber + withDisplayName:(NSString*)ABRecordCopyCompositeName(person)]; return false; } - (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker { - [linphoneDelegate selectDialerTab]; + [[LinphoneManager instance].uiController displayDialerFromUI:nil + forUser:nil + withDisplayName:@""]; } @end diff --git a/Classes/GenericTabViewController.h b/Classes/GenericTabViewController.h index 1ce13680a..0335ebf13 100644 --- a/Classes/GenericTabViewController.h +++ b/Classes/GenericTabViewController.h @@ -24,13 +24,8 @@ @interface GenericTabViewController : UITableViewController { LinphoneCore* myLinphoneCore; - id phoneControllerDelegate; - id linphoneDelegate; IBOutlet UIView* header; } --(void) setLinphoneCore:(LinphoneCore*) lc; -@property (nonatomic, retain) id phoneControllerDelegate; -@property (nonatomic, retain) id linphoneDelegate; @property (nonatomic, retain) IBOutlet UIView* header; @end diff --git a/Classes/GenericTabViewController.m b/Classes/GenericTabViewController.m index 3aed6191f..ed716dd48 100644 --- a/Classes/GenericTabViewController.m +++ b/Classes/GenericTabViewController.m @@ -21,8 +21,6 @@ @implementation GenericTabViewController -@synthesize phoneControllerDelegate; -@synthesize linphoneDelegate; @synthesize header; @@ -36,9 +34,7 @@ [self.tableView reloadData]; } --(void) setLinphoneCore:(LinphoneCore*) lc { - myLinphoneCore = lc; -} + - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { diff --git a/Classes/IncallViewController.h b/Classes/IncallViewController.h new file mode 100644 index 000000000..9a5771276 --- /dev/null +++ b/Classes/IncallViewController.h @@ -0,0 +1,102 @@ +/* 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 "linphonecore.h" +#import "PhoneViewController.h" +#import + + +@interface IncallViewController : UIViewController { + LinphoneCore* myLinphoneCore; + id phoneviewDelegate; + NSTimer *durationRefreasher; + + + UIView* controlSubView; + UIView* padSubView; + + UILabel* peerName; + UILabel* peerNumber; + UILabel* callDuration; + UILabel* status; + UIButton* end; + UIButton* dialer; + UIButton* mute; + UIButton* speaker; + UIButton* contacts; + + //key pad + UIButton* one; + UIButton* two; + UIButton* three; + UIButton* four; + UIButton* five; + UIButton* six; + UIButton* seven; + UIButton* eight; + UIButton* nine; + UIButton* star; + UIButton* zero; + UIButton* hash; + + UIButton* close; + + bool isMuted; + bool isSpeaker; + + ABPeoplePickerNavigationController* myPeoplePickerController; +} + +-(void) setLinphoneCore:(LinphoneCore*) lc; +-(void) startCall; + +-(void)displayStatus:(NSString*) message; + +- (IBAction)doAction:(id)sender; + +@property (nonatomic, retain) IBOutlet UIView* controlSubView; +@property (nonatomic, retain) IBOutlet UIView* padSubView; + +@property (nonatomic, retain) IBOutlet UILabel* peerName; +@property (nonatomic, retain) IBOutlet UILabel* peerNumber; +@property (nonatomic, retain) IBOutlet UILabel* callDuration; +@property (nonatomic, retain) IBOutlet UILabel* status; +@property (nonatomic, retain) IBOutlet UIButton* end; +@property (nonatomic, retain) IBOutlet UIButton* dialer; +@property (nonatomic, retain) IBOutlet UIButton* mute; +@property (nonatomic, retain) IBOutlet UIButton* speaker; +@property (nonatomic, retain) IBOutlet UIButton* contacts; + + +@property (nonatomic, retain) IBOutlet UIButton* one; +@property (nonatomic, retain) IBOutlet UIButton* two; +@property (nonatomic, retain) IBOutlet UIButton* three; +@property (nonatomic, retain) IBOutlet UIButton* four; +@property (nonatomic, retain) IBOutlet UIButton* five; +@property (nonatomic, retain) IBOutlet UIButton* six; +@property (nonatomic, retain) IBOutlet UIButton* seven; +@property (nonatomic, retain) IBOutlet UIButton* eight; +@property (nonatomic, retain) IBOutlet UIButton* nine; +@property (nonatomic, retain) IBOutlet UIButton* star; +@property (nonatomic, retain) IBOutlet UIButton* zero; +@property (nonatomic, retain) IBOutlet UIButton* hash; +@property (nonatomic, retain) IBOutlet UIButton* close; + +@property (nonatomic, retain) id phoneviewDelegate; +@end diff --git a/Classes/IncallViewController.m b/Classes/IncallViewController.m new file mode 100644 index 000000000..73493fca2 --- /dev/null +++ b/Classes/IncallViewController.m @@ -0,0 +1,243 @@ +/* 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 "IncallViewController.h" +#import +#import "linphonecore.h" + + + +@implementation IncallViewController +@synthesize phoneviewDelegate; + +@synthesize controlSubView; +@synthesize padSubView; + +@synthesize peerName; +@synthesize peerNumber; +@synthesize callDuration; +@synthesize status; +@synthesize end; +@synthesize close; +@synthesize mute; +@synthesize dialer; +@synthesize speaker; +@synthesize contacts; + +@synthesize one; +@synthesize two; +@synthesize three; +@synthesize four; +@synthesize five; +@synthesize six; +@synthesize seven; +@synthesize eight; +@synthesize nine; +@synthesize star; +@synthesize zero; +@synthesize hash; + + +/* +// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { + // Custom initialization + + } + return self; +} +*/ + + +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad { + [super viewDidLoad]; + isMuted = false; + isSpeaker = false; + +} + + +/* + // Override to allow orientations other than the default portrait orientation. + - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations + return (interfaceOrientation == UIInterfaceOrientationPortrait); + } + */ + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; + if (durationRefreasher != nil) { + [ durationRefreasher invalidate]; + } + +} + +-(void) setLinphoneCore:(LinphoneCore*) lc { + myLinphoneCore = lc; +} + +-(void)displayStatus:(NSString*) message { + [status setText:message]; +} + +-(void) startCall { + const LinphoneAddress* address = linphone_core_get_remote_uri(myLinphoneCore); + const char* displayName = linphone_address_get_display_name(address)?linphone_address_get_display_name(address):""; + [peerName setText:[NSString stringWithCString:displayName length:strlen(displayName)]]; + + const char* username = linphone_address_get_username(address)!=0?linphone_address_get_username(address):""; + [peerNumber setText:[NSString stringWithCString:username length:strlen(username)]]; + // start scheduler + durationRefreasher = [NSTimer scheduledTimerWithTimeInterval:1 + target:self + selector:@selector(updateCallDuration) + userInfo:nil + repeats:YES]; + +} + +-(void)updateCallDuration { + int lDuration = linphone_core_get_current_call_duration(myLinphoneCore); + if (lDuration < 60) { + [callDuration setText:[NSString stringWithFormat: @"%i s", lDuration]]; + } else { + [callDuration setText:[NSString stringWithFormat: @"%i:%i", lDuration/60,lDuration - 60 *(lDuration/60)]]; + } +} + +- (IBAction)doAction:(id)sender { + + if (linphone_core_in_call(myLinphoneCore)) { + //incall behavior + if (sender == one) { + linphone_core_send_dtmf(myLinphoneCore,'1'); + } else if (sender == two) { + linphone_core_send_dtmf(myLinphoneCore,'2'); + } else if (sender == three) { + linphone_core_send_dtmf(myLinphoneCore,'3'); + } else if (sender == four) { + linphone_core_send_dtmf(myLinphoneCore,'4'); + } else if (sender == five) { + linphone_core_send_dtmf(myLinphoneCore,'5'); + } else if (sender == six) { + linphone_core_send_dtmf(myLinphoneCore,'6'); + } else if (sender == seven) { + linphone_core_send_dtmf(myLinphoneCore,'7'); + } else if (sender == eight) { + linphone_core_send_dtmf(myLinphoneCore,'8'); + } else if (sender == nine) { + linphone_core_send_dtmf(myLinphoneCore,'9'); + } else if (sender == star) { + linphone_core_send_dtmf(myLinphoneCore,'*'); + } else if (sender == zero) { + linphone_core_send_dtmf(myLinphoneCore,'0'); + } else if (sender == hash) { + linphone_core_send_dtmf(myLinphoneCore,'#'); + } + } + + + if (sender == end) { + linphone_core_terminate_call(myLinphoneCore,NULL); + } else if (sender == dialer) { + [controlSubView setHidden:true]; + [padSubView setHidden:false]; + + } else if (sender == contacts) { + // start people picker + myPeoplePickerController = [[[ABPeoplePickerNavigationController alloc] init] autorelease]; + [myPeoplePickerController setPeoplePickerDelegate:self]; + + [self presentModalViewController: myPeoplePickerController animated:true]; + } else if (sender == close) { + [controlSubView setHidden:false]; + [padSubView setHidden:true]; + } else if (sender == mute) { + isMuted = isMuted?false:true; + linphone_core_mute_mic(myLinphoneCore,isMuted); + // swithc buttun state + UIImage * tmpImage = [mute backgroundImageForState: UIControlStateNormal]; + [mute setBackgroundImage:[mute backgroundImageForState: UIControlStateHighlighted] forState:UIControlStateNormal]; + [mute setBackgroundImage:tmpImage forState:UIControlStateHighlighted]; + + } else if (sender == speaker) { + isSpeaker = isSpeaker?false:true; + if (isSpeaker) { + //redirect audio to speaker + UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; + AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute + , sizeof (audioRouteOverride) + , &audioRouteOverride); + } else { + //Cancel audio route redirection + UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_None; + AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute + , sizeof (audioRouteOverride) + , &audioRouteOverride); + } + // switch button state + UIImage * tmpImage = [speaker backgroundImageForState: UIControlStateNormal]; + [speaker setBackgroundImage:[speaker backgroundImageForState: UIControlStateHighlighted] forState:UIControlStateNormal]; + [speaker setBackgroundImage:tmpImage forState:UIControlStateHighlighted]; + + }else { + NSLog(@"unknown event from incall view"); + } + +} + +// handle people picker behavior + +- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker + shouldContinueAfterSelectingPerson:(ABRecordRef)person { + return true; + +} + +- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker + shouldContinueAfterSelectingPerson:(ABRecordRef)person + property:(ABPropertyID)property + identifier:(ABMultiValueIdentifier)identifier { + + return false; +} + +- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker { + [self dismissModalViewControllerAnimated:true]; +} + + + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/Classes/IncallViewController.xib b/Classes/IncallViewController.xib new file mode 100644 index 000000000..9df78c3e6 --- /dev/null +++ b/Classes/IncallViewController.xib @@ -0,0 +1,1740 @@ + + + + 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 + + + + + 274 + + YES + + + 292 + {{150, 220}, {20, 20}} + + NO + NO + NO + IBCocoaTouchFramework + NO + 2 + + + + 292 + {320, 55} + + NO + YES + NO + IBCocoaTouchFramework + Caller + + 1 + MCAwIDAAA + + + 1 + 17 + 1 + + + + 292 + {{31, 63}, {61, 21}} + + NO + YES + NO + IBCocoaTouchFramework + Number + + + 1 + 10 + + + + 292 + {{239, 63}, {65, 21}} + + NO + YES + NO + IBCocoaTouchFramework + Duration + + + 1 + 10 + + + + 292 + {{31, 347}, {258, 21}} + + NO + YES + NO + IBCocoaTouchFramework + status + + + 1 + 10 + + + + 292 + + YES + + + 292 + {{0, 61}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + Helvetica-Bold + 15 + 16 + + + 3 + MQA + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + 3 + MC41AA + + + NSImage + mic_active.png + + + NSImage + mic_muted.png + + + + + + + 292 + {{6, 261}, {258, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + NSImage + stopcall-red.png + + + + + 292 + {{92, 121}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + Contacts + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + NSImage + contact-orange.png + + + + + 292 + {{93, 61}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + Dialer + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + NSImage + dialer-orange.png + + + + + 292 + {{181, 61}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + Spk + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + NSImage + Speaker-32-off.png + + + + {{25, 110}, {270, 317}} + + + 3 + MSAwAA + + 2 + + + NO + NO + IBCocoaTouchFramework + + + + -2147483356 + + YES + + + 292 + {{30, 258}, {80, 65}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + + 292 + {{170, 266}, {72, 37}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + close + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + 292 + {{90, 184}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + 0 + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + 292 + {{0, 9}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + 1 + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + 292 + {{90, 9}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + 2 + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + 292 + {{180, 9}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + 3 + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + 292 + {{0, 69}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + 4 + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + 292 + {{90, 69}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + 5 + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + 292 + {{180, 69}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + 6 + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + 292 + {{0, 124}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + 7 + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + 292 + {{90, 124}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + 8 + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + 292 + {{180, 124}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + 9 + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + 292 + {{0, 184}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + * + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + + 292 + {{180, 184}, {82, 52}} + + NO + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + # + + + 1 + MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA + + + + + {{25, 110}, {270, 317}} + + + 3 + MSAwAA + + + NO + NO + IBCocoaTouchFramework + + + {320, 460} + + + 1 + MC44MDAwMDAwMTE5IDAuODAwMDAwMDExOSAwLjgwMDAwMDAxMTkAA + + NO + IBCocoaTouchFramework + + + + 1 + + IBCocoaTouchFramework + NO + + + + + YES + + + doAction: + + + 7 + + 20 + + + + view + + + + 23 + + + + doAction: + + + 7 + + 42 + + + + controlSubView + + + + 44 + + + + padSubView + + + + 45 + + + + doAction: + + + 7 + + 47 + + + + dialer + + + + 49 + + + + doAction: + + + 7 + + 50 + + + + close + + + + 51 + + + + end + + + + 53 + + + + one + + + + 54 + + + + zero + + + + 55 + + + + star + + + + 56 + + + + hash + + + + 57 + + + + nine + + + + 58 + + + + two + + + + 59 + + + + three + + + + 60 + + + + doAction: + + + 1 + + 61 + + + + doAction: + + + 1 + + 62 + + + + doAction: + + + 1 + + 63 + + + + doAction: + + + 1 + + 64 + + + + doAction: + + + 1 + + 65 + + + + doAction: + + + 1 + + 66 + + + + four + + + + 67 + + + + doAction: + + + 1 + + 68 + + + + five + + + + 69 + + + + doAction: + + + 1 + + 70 + + + + six + + + + 71 + + + + doAction: + + + 1 + + 72 + + + + seven + + + + 73 + + + + doAction: + + + 1 + + 74 + + + + eight + + + + 75 + + + + doAction: + + + 1 + + 76 + + + + doAction: + + + 1 + + 77 + + + + mute + + + + 80 + + + + doAction: + + + 7 + + 81 + + + + speaker + + + + 82 + + + + doAction: + + + 7 + + 83 + + + + contacts + + + + 84 + + + + doAction: + + + 7 + + 85 + + + + peerName + + + + 89 + + + + peerNumber + + + + 90 + + + + callDuration + + + + 91 + + + + status + + + + 94 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 2 + + + YES + + + + + + 9 + + + YES + + + + + + + + + + + + 10 + + + peerName + + + 11 + + + peerNumber + + + 12 + + + duration + + + 26 + + + YES + + + + + + + + controls + + + 13 + + + speaker + + + 17 + + + dialer + + + 18 + + + end + + + 16 + + + mute + + + 15 + + + contacts + + + 27 + + + YES + + + + + + + + + + + + + + + + + pad + + + 28 + + + end + + + 29 + + + close + + + 30 + + + 1 + + + 31 + + + start + + + 32 + + + 9 + + + 33 + + + 8 + + + 34 + + + 7 + + + 35 + + + 4 + + + 36 + + + 5 + + + 37 + + + 6 + + + 38 + + + 3 + + + 39 + + + 2 + + + 40 + + + hash + + + 41 + + + 0 + + + 92 + + + + + 93 + + + status + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 10.IBPluginDependency + 11.IBPluginDependency + 12.IBPluginDependency + 13.IBPluginDependency + 15.IBPluginDependency + 16.IBPluginDependency + 17.IBPluginDependency + 18.IBPluginDependency + 2.IBEditorWindowLastContentRect + 2.IBPluginDependency + 26.IBPluginDependency + 27.IBPluginDependency + 28.IBPluginDependency + 29.IBPluginDependency + 30.IBPluginDependency + 31.IBPluginDependency + 32.IBPluginDependency + 33.IBPluginDependency + 34.IBPluginDependency + 35.IBPluginDependency + 36.IBPluginDependency + 37.IBPluginDependency + 38.IBPluginDependency + 39.IBPluginDependency + 40.IBPluginDependency + 41.IBPluginDependency + 9.IBPluginDependency + 92.IBPluginDependency + 93.IBPluginDependency + + + YES + IncallViewController + UIResponder + 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 + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + {{14, 634}, {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 + 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 + 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 + + + + YES + + + YES + + + + + YES + + + YES + + + + 94 + + + + YES + + IncallViewController + UIViewController + + doAction: + id + + + doAction: + + doAction: + id + + + + YES + + YES + callDuration + close + contacts + controlSubView + dialer + eight + end + five + four + hash + mute + nine + one + padSubView + peerName + peerNumber + phoneviewDelegate + seven + six + speaker + star + status + three + two + zero + + + YES + UILabel + UIButton + UIButton + UIView + UIButton + UIButton + UIButton + UIButton + UIButton + UIButton + UIButton + UIButton + UIButton + UIView + UILabel + UILabel + id + UIButton + UIButton + UIButton + UIButton + UILabel + UIButton + UIButton + UIButton + + + + YES + + YES + callDuration + close + contacts + controlSubView + dialer + eight + end + five + four + hash + mute + nine + one + padSubView + peerName + peerNumber + phoneviewDelegate + seven + six + speaker + star + status + three + two + zero + + + YES + + callDuration + UILabel + + + close + UIButton + + + contacts + UIButton + + + controlSubView + UIView + + + dialer + UIButton + + + eight + UIButton + + + end + UIButton + + + five + UIButton + + + four + UIButton + + + hash + UIButton + + + mute + UIButton + + + nine + UIButton + + + one + UIButton + + + padSubView + UIView + + + peerName + UILabel + + + peerNumber + UILabel + + + phoneviewDelegate + id + + + seven + UIButton + + + six + UIButton + + + speaker + UIButton + + + star + UIButton + + + status + UILabel + + + three + UIButton + + + two + UIButton + + + zero + UIButton + + + + + IBProjectSource + Classes/IncallViewController.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 + + + + 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 + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIPrintFormatter.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + 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 + + YES + + YES + Speaker-32-off.png + contact-orange.png + dialer-orange.png + mic_active.png + mic_muted.png + stopcall-red.png + + + YES + {32, 32} + {25, 23} + {25, 24} + {32, 32} + {32, 32} + {62, 54} + + + 132 + + diff --git a/Classes/LinphoneUI/LinphoneManager.h b/Classes/LinphoneUI/LinphoneManager.h new file mode 100644 index 000000000..f7ccd3309 --- /dev/null +++ b/Classes/LinphoneUI/LinphoneManager.h @@ -0,0 +1,51 @@ +/* LinphoneManager.h + * + * Copyright (C) 2011 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 +#include "linphonecore.h" +#import "LogView.h" +#import "LinphoneUIControler.h" + +@interface LinphoneManager : NSObject { +@private + SCNetworkReachabilityContext proxyReachabilityContext; + SCNetworkReachabilityRef proxyReachability; + CFReadStreamRef mReadStream; + NSTimer* mIterateTimer; + id mLogView; + bool isbackgroundModeEnabled; + id uiController; + UIViewController* mCurrentViewController; + +} ++(LinphoneManager*) instance; ++(LinphoneCore*) getLc; + +-(void) registerLogView:(id) view; + +-(void) startLibLinphone; +-(void) destroyLibLinphone; + +-(void) enterBackgroundMode; +-(void) becomeActive; +-(void) kickOffNetworkConnection; + +@property (nonatomic, retain) id uiController; +@end diff --git a/Classes/LinphoneUI/LinphoneManager.m b/Classes/LinphoneUI/LinphoneManager.m new file mode 100644 index 000000000..2812d3730 --- /dev/null +++ b/Classes/LinphoneUI/LinphoneManager.m @@ -0,0 +1,611 @@ +/* LinphoneManager.h + * + * Copyright (C) 2011 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 "LinphoneManager.h" +#include "linphonecore.h" +#include +#include +#include +#import +#import + +static LinphoneCore* theLinphoneCore=nil; +static LinphoneManager* theLinphoneManager=nil; + +extern void libmsilbc_init(); + + +@implementation LinphoneManager +@synthesize uiController; + ++(LinphoneManager*) instance { + if (theLinphoneManager==nil) { + theLinphoneManager = [LinphoneManager alloc]; + } + return theLinphoneManager; +} + +-(void) onCall:(LinphoneCall*) currentCall StateChanged: (LinphoneCallState) new_state withMessage: (const char *) message { + NSString* lUserName = [[NSString alloc] initWithCString:linphone_address_get_username(linphone_call_get_remote_address(currentCall))]; + const char* lDisplayNameChars = linphone_address_get_display_name(linphone_call_get_remote_address(currentCall)); + NSString* lDisplayName = lDisplayNameChars?[[NSString alloc] initWithCString:lDisplayNameChars]:@""; + + switch (new_state) { + + case LinphoneCallIncomingReceived: + [uiController displayIncomingCallNotigicationFromUI:mCurrentViewController + forUser:lUserName + withDisplayName:lDisplayName]; + break; + + case LinphoneCallOutgoingInit: + [uiController displayCallInProgressFromUI:mCurrentViewController + forUser:lUserName + withDisplayName:lDisplayName]; + break; + + case LinphoneCallConnected: + [uiController displayIncallFromUI:mCurrentViewController + forUser:lUserName + withDisplayName:lDisplayName]; + break; + + case LinphoneCallError: { + /* + NSString* lTitle= state->message!=nil?[NSString stringWithCString:state->message length:strlen(state->message)]: @"Error"; + NSString* lMessage=lTitle; + */ + NSString* lMessage; + NSString* lTitle; + + + lMessage=@"Please make sure your device is connected to the internet and double check your SIP account configuration in the settings."; + + if (message!=nil){ + lMessage=[NSString stringWithFormat : @"%@\nReason was: %s",lMessage, message]; + } + lTitle=@"Call failed"; + + UIAlertView* error = [[UIAlertView alloc] initWithTitle:lTitle + message:lMessage + delegate:nil + cancelButtonTitle:@"Dismiss" + otherButtonTitles:nil]; + [error show]; + [uiController displayDialerFromUI:mCurrentViewController + forUser:@"" + withDisplayName:@""]; + break; + } + case LinphoneCallEnd: + [uiController displayDialerFromUI:mCurrentViewController + forUser:@"" + withDisplayName:@""]; + break; + default: + break; + } + +} + ++(LinphoneCore*) getLc { + if (theLinphoneCore==nil) { + @throw([NSException exceptionWithName:@"LinphoneCoreException" reason:@"Linphone core not initialized yet" userInfo:nil]); + } + return theLinphoneCore; +} + +-(void) addLog:(NSString*) log { + [mLogView addLog:log]; +} +-(void)displayStatus:(NSString*) message { + [uiController displayStatus:message]; +} +//generic log handler for debug version +static void linphone_iphone_log_handler(int lev, const char *fmt, va_list args){ + NSString* format = [[NSString alloc] initWithCString:fmt encoding:[NSString defaultCStringEncoding]]; + NSLogv(format,args); + NSString* formatedString = [[NSString alloc] initWithFormat:format arguments:args]; + [[LinphoneManager instance] addLog:formatedString]; + [format release]; + [formatedString release]; +} + +//Error/warning log handler +static void linphone_iphone_log(struct _LinphoneCore * lc, const char * message) { + NSString* log = [NSString stringWithCString:message encoding:[NSString defaultCStringEncoding]]; + NSLog(log,NULL); + [[LinphoneManager instance]addLog:log]; +} +//status +static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char * message) { + [(LinphoneManager*)linphone_core_get_user_data(lc) displayStatus:[[NSString alloc] initWithCString:message encoding:[NSString defaultCStringEncoding]]]; +} + +static void linphone_iphone_call_state(LinphoneCore *lc, LinphoneCall* call, LinphoneCallState state,const char* message) { + /*LinphoneCallIdle, + LinphoneCallIncomingReceived, + LinphoneCallOutgoingInit, + LinphoneCallOutgoingProgress, + LinphoneCallOutgoingRinging, + LinphoneCallOutgoingEarlyMedia, + LinphoneCallConnected, + LinphoneCallStreamsRunning, + LinphoneCallPausing, + LinphoneCallPaused, + LinphoneCallResuming, + LinphoneCallRefered, + LinphoneCallError, + LinphoneCallEnd, + LinphoneCallPausedByRemote + */ + [(LinphoneManager*)linphone_core_get_user_data(lc) onCall:call StateChanged: state withMessage: message]; + + + +} + +static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyConfig* cfg, LinphoneRegistrationState state,const char* message) { + 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) { + + + UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Registration failure" + message:lErrorMessage + delegate:nil + cancelButtonTitle:@"Continue" + otherButtonTitles:nil ,nil]; + [error show]; + } + + } + +} + +static LinphoneCoreVTable linphonec_vtable = { + .show =NULL, + .call_state_changed =(LinphoneCallStateCb)linphone_iphone_call_state, + .registration_state_changed = linphone_iphone_registration_state, + .notify_recv = NULL, + .new_subscription_request = NULL, + .auth_info_requested = NULL, + .display_status = linphone_iphone_display_status, + .display_message=linphone_iphone_log, + .display_warning=linphone_iphone_log, + .display_url=NULL, + .text_received=NULL, + .dtmf_received=NULL +}; + + +-(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]; +} +-(void) runNetworkConnection { + CFWriteStreamRef writeStream; + CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"192.168.0.200"/*"linphone.org"*/, 15000, nil, &writeStream); + CFWriteStreamOpen (writeStream); + const char* buff="hello"; + CFWriteStreamWrite (writeStream,(const UInt8*)buff,strlen(buff)); + CFWriteStreamClose (writeStream); +} + +void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void * info) { + ms_message("Network connection flag [%x]",flags); + if ([LinphoneManager getLc] != nil) { + if ((flags == 0) | (flags & (kSCNetworkReachabilityFlagsConnectionRequired |kSCNetworkReachabilityFlagsConnectionOnTraffic))) { + [[LinphoneManager instance] kickOffNetworkConnection]; + linphone_core_set_network_reachable([LinphoneManager getLc],false); + } else { + linphone_core_set_network_reachable([LinphoneManager getLc],true); + } + + } +} +-(void) doRegister { + SCNetworkReachabilityFlags reachabilityFlags; + SCNetworkReachabilityGetFlags (proxyReachability,&reachabilityFlags); + networkReachabilityCallBack(proxyReachability,reachabilityFlags,self); +} + +-(void) doLinphoneConfiguration:(NSNotification *)notification { + ms_message("Configuring Linphone"); + + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"debugenable_preference"]) { + //redirect all traces to the iphone log framework + linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler); + } + else { + linphone_core_disable_logs(); + } + NSString* transport = [[NSUserDefaults standardUserDefaults] stringForKey:@"transport_preference"]; + + //initial state is network off should be done as soon as possible + linphone_core_set_network_reachable(theLinphoneCore,false); + + LCSipTransports transportValue; + if (transport!=nil) { + if (linphone_core_get_sip_transports(theLinphoneCore, &transportValue)) { + ms_error("cannot get current transport"); + } + if ([transport isEqualToString:@"tcp"]) { + if (transportValue.tcp_port == 0) transportValue.tcp_port=transportValue.udp_port; + transportValue.udp_port=0; + } else if ([transport isEqualToString:@"udp"]){ + if (transportValue.udp_port == 0) transportValue.udp_port=transportValue.tcp_port; + transportValue.tcp_port=0; + } else { + ms_error("unexpected trasnport [%s]",[transport cStringUsingEncoding:[NSString defaultCStringEncoding]]); + } + if (linphone_core_set_sip_transports(theLinphoneCore, &transportValue)) { + ms_error("cannot set transport"); + } + } + + + + + // Set audio assets + NSBundle* myBundle = [NSBundle mainBundle]; + const char* lRing = [[myBundle pathForResource:@"oldphone-mono"ofType:@"wav"] cStringUsingEncoding:[NSString defaultCStringEncoding]]; + linphone_core_set_ring(theLinphoneCore, lRing ); + const char* lRingBack = [[myBundle pathForResource:@"ringback"ofType:@"wav"] cStringUsingEncoding:[NSString defaultCStringEncoding]]; + linphone_core_set_ringback(theLinphoneCore, lRingBack); + + + + + //configure sip account + + //madatory parameters + + NSString* username = [[NSUserDefaults standardUserDefaults] stringForKey:@"username_preference"]; + NSString* domain = [[NSUserDefaults standardUserDefaults] stringForKey:@"domain_preference"]; + NSString* accountPassword = [[NSUserDefaults standardUserDefaults] stringForKey:@"password_preference"]; + bool configCheckDisable = [[NSUserDefaults standardUserDefaults] boolForKey:@"check_config_disable_preference"]; + bool isOutboundProxy= [[NSUserDefaults standardUserDefaults] boolForKey:@"outbound_proxy_preference"]; + + + //clear auth info list + linphone_core_clear_all_auth_info(theLinphoneCore); + //clear existing proxy config + linphone_core_clear_proxy_config(theLinphoneCore); + if (proxyReachability !=nil) { + SCNetworkReachabilityUnscheduleFromRunLoop(proxyReachability,CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + } + if (username && [username length] >0 && domain && [domain length]>0) { + + + const char* identity = [[NSString stringWithFormat:@"sip:%@@%@",username,domain] cStringUsingEncoding:[NSString defaultCStringEncoding]]; + const char* password = [accountPassword cStringUsingEncoding:[NSString defaultCStringEncoding]]; + + NSString* proxyAddress = [[NSUserDefaults standardUserDefaults] stringForKey:@"proxy_preference"]; + if ((!proxyAddress | [proxyAddress length] <1 ) && domain) { + proxyAddress = [NSString stringWithFormat:@"sip:%@",domain] ; + } else { + proxyAddress = [NSString stringWithFormat:@"sip:%@",proxyAddress] ; + } + + const char* proxy = [proxyAddress cStringUsingEncoding:[NSString defaultCStringEncoding]]; + + NSString* prefix = [[NSUserDefaults standardUserDefaults] stringForKey:@"prefix_preference"]; + //possible valid config detected + LinphoneProxyConfig* proxyCfg; + proxyCfg = linphone_proxy_config_new(); + + // add username password + LinphoneAddress *from = linphone_address_new(identity); + LinphoneAuthInfo *info; + if (from !=0){ + info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,NULL,NULL); + linphone_core_add_auth_info(theLinphoneCore,info); + } + linphone_address_destroy(from); + + // configure proxy entries + linphone_proxy_config_set_identity(proxyCfg,identity); + linphone_proxy_config_set_server_addr(proxyCfg,proxy); + linphone_proxy_config_enable_register(proxyCfg,true); + + if (isOutboundProxy) + linphone_proxy_config_set_route(proxyCfg,proxy); + + if ([prefix length]>0) { + linphone_proxy_config_set_dial_prefix(proxyCfg, [prefix cStringUsingEncoding:[NSString defaultCStringEncoding]]); + } + linphone_proxy_config_set_dial_escape_plus(proxyCfg,TRUE); + + linphone_core_add_proxy_config(theLinphoneCore,proxyCfg); + //set to default proxy + linphone_core_set_default_proxy(theLinphoneCore,proxyCfg); + + LinphoneAddress* addr=linphone_address_new(linphone_proxy_config_get_addr(proxyCfg)); + proxyReachability=SCNetworkReachabilityCreateWithName(nil, linphone_address_get_domain(addr)); + + + + [self doRegister]; + } else { + if (configCheckDisable == false) { + UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Warning" + message:@"It seems you have not configured any proxy server from settings" + delegate:self + cancelButtonTitle:@"Continue" + otherButtonTitles:@"Never remind",nil]; + [error show]; + } + + proxyReachability=SCNetworkReachabilityCreateWithName(nil, "linphone.org"); + } + proxyReachabilityContext.info=self; + SCNetworkReachabilitySetCallback(proxyReachability, (SCNetworkReachabilityCallBack)networkReachabilityCallBack,&proxyReachabilityContext); + SCNetworkReachabilityScheduleWithRunLoop(proxyReachability, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + + //Configure Codecs + + PayloadType *pt; + //get codecs from linphonerc + const MSList *audioCodecs=linphone_core_get_audio_codecs(theLinphoneCore); + const MSList *elem; + //disable all codecs + for (elem=audioCodecs;elem!=NULL;elem=elem->next){ + pt=(PayloadType*)elem->data; + linphone_core_enable_payload_type(theLinphoneCore,pt,FALSE); + } + + //read codecs from setting bundle and enable them one by one + [self configurePayloadType:"speex" fromPrefKey:@"speex_16k_preference" withRate:16000]; + [self configurePayloadType:"speex" fromPrefKey:@"speex_8k_preference" withRate:8000]; + [self configurePayloadType:"GSM" fromPrefKey:@"gsm_8k_preference" withRate:8000]; + [self configurePayloadType:"iLBC" fromPrefKey:@"ilbc_preference" withRate:8000]; + [self configurePayloadType:"PCMU" fromPrefKey:@"pcmu_preference" withRate:8000]; + [self configurePayloadType:"PCMA" fromPrefKey:@"pcma_preference" withRate:8000]; + + UIDevice* device = [UIDevice currentDevice]; + bool backgroundSupported = false; + if ([device respondsToSelector:@selector(isMultitaskingSupported)]) + backgroundSupported = [device isMultitaskingSupported]; + + if (backgroundSupported) { + isbackgroundModeEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"backgroundmode_preference"]; + } else { + isbackgroundModeEnabled=false; + } + + + +} +-(void) destroyLibLinphone { + [mIterateTimer invalidate]; + if (theLinphoneCore != nil) { //just in case application terminate before linphone core initialization + linphone_core_destroy(theLinphoneCore); + theLinphoneCore = nil; + } +} + +//**********************BG mode management*************************/////////// +-(void) enterBackgroundMode { + + struct addrinfo hints; + struct addrinfo *res=NULL; + int err; + + LinphoneProxyConfig* proxyCfg; + LinphoneAddress *addr; + linphone_core_get_default_proxy(theLinphoneCore, &proxyCfg); + + if (isbackgroundModeEnabled && proxyCfg) { + //For registration register + linphone_core_set_network_reachable(theLinphoneCore,false); + linphone_core_iterate(theLinphoneCore); + linphone_core_set_network_reachable(theLinphoneCore,true); + + + //wait for registration answer + int i=0; + while (!linphone_proxy_config_is_registered(proxyCfg) && i++<40 ) { + linphone_core_iterate(theLinphoneCore); + usleep(100000); + } + //register keepalive + if ([[UIApplication sharedApplication] setKeepAliveTimeout:600/*(NSTimeInterval)linphone_proxy_config_get_expires(proxyCfg)*/ + handler:^{ + ms_warning("keepalive handler"); + //kick up network cnx, just in case + linphone_core_set_network_reachable(theLinphoneCore,false); + linphone_core_iterate(theLinphoneCore); + [self kickOffNetworkConnection]; + linphone_core_set_network_reachable(theLinphoneCore,true); + linphone_core_iterate(theLinphoneCore); + } + ]) { + + + ms_warning("keepalive handler succesfully registered"); + } else { + ms_warning("keepalive handler cannot be registered"); + } + LCSipTransports transportValue; + if (linphone_core_get_sip_transports(theLinphoneCore, &transportValue)) { + ms_error("cannot get current transport"); + } + + if (mReadStream == nil && transportValue.udp_port>0) { //only for udp + int sipsock = linphone_core_get_sip_socket(theLinphoneCore); + //disable keepalive handler + linphone_core_enable_keep_alive(theLinphoneCore, false); + const char *port; + addr=linphone_address_new(linphone_proxy_config_get_addr(proxyCfg)); + memset(&hints,0,sizeof(hints)); + hints.ai_family=linphone_core_ipv6_enabled(theLinphoneCore) ? AF_INET6 : AF_INET; + port=linphone_address_get_port(addr); + if (port==NULL) port="5060"; + err=getaddrinfo(linphone_address_get_domain(addr),port,&hints,&res); + if (err!=0){ + ms_error("getaddrinfo() failed for %s: %s",linphone_address_get_domain(addr),gai_strerror(err)); + linphone_address_destroy(addr); + return; + } + err=connect(sipsock,res->ai_addr,res->ai_addrlen); + if (err==-1){ + ms_error("Connect failed: %s",strerror(errno)); + } + freeaddrinfo(res); + + CFStreamCreatePairWithSocket(NULL, (CFSocketNativeHandle)sipsock, &mReadStream,nil); + + if (!CFReadStreamSetProperty(mReadStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP)) { + ms_error("cannot set service type to voip for read stream"); + } + + + if (!CFReadStreamOpen(mReadStream)) { + ms_error("cannot open read stream"); + } + } + } + else { + ms_warning("Entering lite bg mode"); + [self destroyLibLinphone]; + } + +} + + +//scheduling loop +-(void) iterate { + linphone_core_iterate(theLinphoneCore); +} + + + + + +/************* + *lib linphone init method + */ +-(void)startLibLinphone { + + //get default config from bundle + NSBundle* myBundle = [NSBundle mainBundle]; + NSString* factoryConfig = [myBundle pathForResource:@"linphonerc"ofType:nil] ; + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *confiFileName = [[paths objectAtIndex:0] stringByAppendingString:@"/.linphonerc"]; + ; + signal(SIGPIPE, SIG_IGN); + //log management + + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"debugenable_preference"]) { + //redirect all traces to the iphone log framework + linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler); + } + else { + linphone_core_disable_logs(); + } + + libmsilbc_init(); + + /* + * Initialize linphone core + */ + + theLinphoneCore = linphone_core_new (&linphonec_vtable + , [confiFileName cStringUsingEncoding:[NSString defaultCStringEncoding]] + , [factoryConfig cStringUsingEncoding:[NSString defaultCStringEncoding]] + ,self); + + [ self doLinphoneConfiguration:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(doLinphoneConfiguration:) + name:NSUserDefaultsDidChangeNotification object:nil]; + + + // start scheduler + mIterateTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 + target:self + selector:@selector(iterate) + userInfo:nil + repeats:YES]; + //init audio session + AVAudioSession *audioSession = [AVAudioSession sharedInstance]; + BOOL bAudioInputAvailable= [audioSession inputIsAvailable]; + + if(!bAudioInputAvailable){ + UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"No microphone" + message:@"You need to plug a microphone to your device to use this application." + delegate:nil + cancelButtonTitle:@"Ok" + otherButtonTitles:nil ,nil]; + [error show]; + } + + + +} +-(void) becomeActive { + if (theLinphoneCore == nil) { + //back from standby and background mode is disabled + [self startLibLinphone]; + + } else { + ms_message("becomming active, make sure we are registered"); + [self doRegister]; + + } + + LCSipTransports transportValue; + if (linphone_core_get_sip_transports(theLinphoneCore, &transportValue)) { + ms_error("cannot get current transport"); + } + if (transportValue.udp_port != 0) { + //enable sip keepalive + linphone_core_enable_keep_alive(theLinphoneCore, true); + } + if (mReadStream !=nil) { + //unconnect + int socket = linphone_core_get_sip_socket(theLinphoneCore); + struct sockaddr hints; + memset(&hints,0,sizeof(hints)); + hints.sa_family=AF_UNSPEC; + connect(socket,&hints,sizeof(hints)); + CFReadStreamClose(mReadStream); + CFRelease(mReadStream); + mReadStream=nil; + } +} +-(void) registerLogView:(id) view { + mLogView = view; +} +@end diff --git a/Classes/LinphoneUI/LinphoneUIControler.h b/Classes/LinphoneUI/LinphoneUIControler.h new file mode 100644 index 000000000..aa0b632c0 --- /dev/null +++ b/Classes/LinphoneUI/LinphoneUIControler.h @@ -0,0 +1,31 @@ +/* LinphoneUIControler.h + * + * Copyright (C) 2011 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 + + +@protocol LinphoneUIControler +// UI changes +-(void) displayDialerFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName; +-(void) displayCallInProgressFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName; +-(void) displayIncomingCallNotigicationFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName; +-(void) displayIncallFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName; +//status reporting +-(void) displayStatus:(NSString*) message; +@end + diff --git a/Classes/LinphoneUI/LogView.h b/Classes/LinphoneUI/LogView.h new file mode 100644 index 000000000..399c35eaa --- /dev/null +++ b/Classes/LinphoneUI/LogView.h @@ -0,0 +1,27 @@ +/* LogView.h + * + * Copyright (C) 2011 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 + + +@protocol LogView +-(void) addLog:(NSString*) log; + +@end + diff --git a/Classes/LinphoneUI/UICallButton.h b/Classes/LinphoneUI/UICallButton.h new file mode 100644 index 000000000..7172e635e --- /dev/null +++ b/Classes/LinphoneUI/UICallButton.h @@ -0,0 +1,30 @@ +/* UICallButton.h + * + * Copyright (C) 2011 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 + + +@interface UICallButton : UIButton { +@private + char mDigit; + UITextField* mAddress; + UILabel* mDisplayName; +} +-(void) initWithAddress:(UITextField*) address withDisplayName:(UILabel*) displayName; +@end diff --git a/Classes/LinphoneUI/UICallButton.m b/Classes/LinphoneUI/UICallButton.m new file mode 100644 index 000000000..5e1905e71 --- /dev/null +++ b/Classes/LinphoneUI/UICallButton.m @@ -0,0 +1,88 @@ +/* UICallButton.m + * + * Copyright (C) 2011 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 "UICallButton.h" +#import "LinphoneManager.h" + + +@implementation UICallButton +-(void) touchUp:(id) sender { + if (!linphone_core_is_network_reachabled([LinphoneManager getLc])) { + UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Network Error" + message:@"There is no network connection available, enable WIFI or WWAN prior to place a call" + delegate:nil + cancelButtonTitle:@"Continue" + otherButtonTitles:nil]; + [error show]; + return; + } + if (!linphone_core_in_call([LinphoneManager getLc])) { + LinphoneProxyConfig* proxyCfg; + //get default proxy + linphone_core_get_default_proxy([LinphoneManager getLc],&proxyCfg); + + if ([mAddress.text length] == 0) return; //just return + if ([mAddress.text hasPrefix:@"sip:"]) { + linphone_core_invite([LinphoneManager getLc], [mAddress.text cStringUsingEncoding:[NSString defaultCStringEncoding]]); + } else if ( proxyCfg==nil){ + UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Invalid sip address" + message:@"Either configure a SIP proxy server from settings prior to place a call or use a valid sip address (I.E sip:john@example.net)" + delegate:nil + cancelButtonTitle:@"Continue" + otherButtonTitles:nil]; + [error show]; + + } else { + char normalizedUserName[256]; + NSString* toUserName = [NSString stringWithString:[mAddress text]]; + linphone_proxy_config_normalize_number(proxyCfg,[toUserName cStringUsingEncoding:[NSString defaultCStringEncoding]],normalizedUserName,sizeof(normalizedUserName)); + LinphoneAddress* tmpAddress = linphone_address_new(linphone_core_get_identity([LinphoneManager getLc])); + linphone_address_set_username(tmpAddress,normalizedUserName); + linphone_address_set_display_name(tmpAddress,[mDisplayName.text length]>0?[mDisplayName.text cStringUsingEncoding:[NSString defaultCStringEncoding]]:nil); + linphone_core_invite([LinphoneManager getLc],linphone_address_as_string(tmpAddress)) ; + linphone_address_destroy(tmpAddress); + } + } else if (linphone_core_inc_invite_pending([LinphoneManager getLc])) { + linphone_core_accept_call([LinphoneManager getLc],linphone_core_get_current_call([LinphoneManager getLc])); + } + +} + + +/* + // Only override drawRect: if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + - (void)drawRect:(CGRect)rect { + // Drawing code. + } + */ +-(void) initWithAddress:(UITextField*) address withDisplayName:(UILabel*) displayName { + mAddress=[address retain]; + mDisplayName = [displayName retain]; + [self addTarget:self action:@selector(touchUp:) forControlEvents:UIControlEventTouchUpInside]; +} + +- (void)dealloc { + [super dealloc]; + [mAddress release]; + +} + + +@end diff --git a/Classes/LinphoneUI/UIDigitButton.h b/Classes/LinphoneUI/UIDigitButton.h new file mode 100644 index 000000000..142dc061a --- /dev/null +++ b/Classes/LinphoneUI/UIDigitButton.h @@ -0,0 +1,30 @@ +/* UIDigitButton.h + * + * Copyright (C) 2011 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 +#include "linphonecore.h" + +@interface UIDigitButton : UIButton { +@private + char mDigit; + UITextField* mAddress; + +} +-(void) initWithNumber:(char)digit addressField:(UITextField*) address; + +@end diff --git a/Classes/LinphoneUI/UIDigitButton.m b/Classes/LinphoneUI/UIDigitButton.m new file mode 100644 index 000000000..a3b5eded9 --- /dev/null +++ b/Classes/LinphoneUI/UIDigitButton.m @@ -0,0 +1,81 @@ +/* UIDigitButton.m + * + * Copyright (C) 2011 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 "UIDigitButton.h" +#include "linphonecore.h" +#import "LinphoneManager.h" + +@implementation UIDigitButton + + + + +-(void) touchDown:(id) sender { + if (!linphone_core_in_call([LinphoneManager getLc])) { + NSString* newAddress = [NSString stringWithFormat:@"%@%c",mAddress.text,mDigit]; + [mAddress setText:newAddress]; + linphone_core_play_dtmf([LinphoneManager getLc], mDigit, -1); + if (mDigit == '0') { + //start timer for + + [self performSelector:@selector(doKeyZeroLongPress) withObject:nil afterDelay:0.5]; + } + } else { + linphone_core_send_dtmf([LinphoneManager getLc],mDigit); + } + +} +-(void) touchUp:(id) sender { + linphone_core_stop_dtmf([LinphoneManager getLc]); + if (mDigit == '0') { + //cancel timer for + + [NSObject cancelPreviousPerformRequestsWithTarget:self + selector:@selector(doKeyZeroLongPress) + object:nil]; + } + + +} + +-(void)doKeyZeroLongPress { + NSString* newAddress = [[mAddress.text substringToIndex: [mAddress.text length]-1] stringByAppendingString:@"+"]; + [mAddress setText:newAddress]; + +} + +-(void) initWithNumber:(char)digit addressField:(UITextField*) address{ + mDigit=digit ; + mAddress=[address retain]; + [self addTarget:self action:@selector(touchDown:) forControlEvents:UIControlEventTouchDown]; + [self addTarget:self action:@selector(touchUp:) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside]; +} +/* + // Only override drawRect: if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + - (void)drawRect:(CGRect)rect { + // Drawing code. + } + */ + +- (void)dealloc { + [super dealloc]; + [mAddress release]; +} + + +@end diff --git a/Classes/LinphoneUI/UIDuration.h b/Classes/LinphoneUI/UIDuration.h new file mode 100644 index 000000000..c3a45fa5c --- /dev/null +++ b/Classes/LinphoneUI/UIDuration.h @@ -0,0 +1,33 @@ +/* UIDuration.h + * + * Copyright (C) 2011 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 + + +@interface UIDuration : UILabel { +@private + NSTimer *durationRefreasher; +} + +-(void) start; +-(void) stop; + +@end diff --git a/Classes/LinphoneUI/UIDuration.m b/Classes/LinphoneUI/UIDuration.m new file mode 100644 index 000000000..429a291aa --- /dev/null +++ b/Classes/LinphoneUI/UIDuration.m @@ -0,0 +1,66 @@ +/* UIDuration.m + * + * Copyright (C) 2011 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 "UIDuration.h" +#import "LinphoneManager.h" + + +@implementation UIDuration + +-(void)updateCallDuration { + int lDuration = linphone_core_get_current_call_duration([LinphoneManager getLc]); + if (lDuration < 60) { + [self setText:[NSString stringWithFormat: @"%02i s", lDuration]]; + } else { + [self setText:[NSString stringWithFormat: @"%02i:%02i", lDuration/60,lDuration - 60 *(lDuration/60)]]; + } +} + +-(void) start { + [self setText:@"00 s"]; + durationRefreasher = [NSTimer scheduledTimerWithTimeInterval:1 + target:self + selector:@selector(updateCallDuration) + userInfo:nil + repeats:YES]; +} +-(void) stop { + [durationRefreasher invalidate]; + durationRefreasher=nil; + +} + + +/* + // Only override drawRect: if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + - (void)drawRect:(CGRect)rect { + // Drawing code. + } + */ + +- (void)dealloc { + [super dealloc]; + [durationRefreasher invalidate]; +} + + +@end diff --git a/Classes/LinphoneUI/UIHangUpButton.h b/Classes/LinphoneUI/UIHangUpButton.h new file mode 100644 index 000000000..0fea2de1e --- /dev/null +++ b/Classes/LinphoneUI/UIHangUpButton.h @@ -0,0 +1,26 @@ +/* UIHangUpButton.h + * + * Copyright (C) 2011 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 + + +@interface UIHangUpButton : UIButton { + +} + +@end diff --git a/Classes/LinphoneUI/UIHangUpButton.m b/Classes/LinphoneUI/UIHangUpButton.m new file mode 100644 index 000000000..bf763f287 --- /dev/null +++ b/Classes/LinphoneUI/UIHangUpButton.m @@ -0,0 +1,58 @@ +/* UIHangUpButton.m + * + * Copyright (C) 2011 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 "UIHangUpButton.h" +#import "LinphoneManager.h" + +@implementation UIHangUpButton + +-(void) touchUp:(id) sender { + linphone_core_terminate_call([LinphoneManager getLc],linphone_core_get_current_call([LinphoneManager getLc])); +} + +- (id)initWithFrame:(CGRect)frame { + + self = [super initWithFrame:frame]; + if (self) { + [self addTarget:self action:@selector(touchUp:) forControlEvents:UIControlEventTouchUpInside]; + } + return self; +} +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (self) { + [self addTarget:self action:@selector(touchUp:) forControlEvents:UIControlEventTouchUpInside]; + } + return self; +} + +/* + // Only override drawRect: if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + - (void)drawRect:(CGRect)rect { + // Drawing code. + } + */ + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/Classes/LinphoneUI/UILinphone.h b/Classes/LinphoneUI/UILinphone.h new file mode 100644 index 000000000..3c74358d7 --- /dev/null +++ b/Classes/LinphoneUI/UILinphone.h @@ -0,0 +1,27 @@ +/* UIHangUpButton.h + * + * Copyright (C) 2011 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 "UICallButton.h" +#import "UIHangUpButton.h" +#import "UIDigitButton.h" +#import "UIToggleButton.h" +#import "UIMuteButton.h" +#import "UISpeakerButton.h" +#import "UIDuration.h" +#import "LinphoneUIControler.h" diff --git a/Classes/LinphoneUI/UIMuteButton.h b/Classes/LinphoneUI/UIMuteButton.h new file mode 100644 index 000000000..975d346db --- /dev/null +++ b/Classes/LinphoneUI/UIMuteButton.h @@ -0,0 +1,28 @@ +/* UIMuteButton.h + * + * Copyright (C) 2011 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 "UIToggleButton.h" + + +@interface UIMuteButton : UIToggleButton { + +} + +@end diff --git a/Classes/LinphoneUI/UIMuteButton.m b/Classes/LinphoneUI/UIMuteButton.m new file mode 100644 index 000000000..d4a4bac90 --- /dev/null +++ b/Classes/LinphoneUI/UIMuteButton.m @@ -0,0 +1,56 @@ +/* UIMuteButton.m + * + * Copyright (C) 2011 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 "UIMuteButton.h" +#include "LinphoneManager.h" + + +@implementation UIMuteButton + + + +-(void) onOn { + linphone_core_mute_mic([LinphoneManager getLc], true); +} +-(void) onOff { + linphone_core_mute_mic([LinphoneManager getLc], false); +} +-(bool) isInitialStateOn { + @try { + return true == linphone_core_is_mic_muted([LinphoneManager getLc]); + } @catch(NSException* e) { + //not ready yet + return false; + } + +} + +/* +// Only override drawRect: if you perform custom drawing. +// An empty implementation adversely affects performance during animation. +- (void)drawRect:(CGRect)rect { + // Drawing code. +} +*/ + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/Classes/LinphoneUI/UISpeakerButton.h b/Classes/LinphoneUI/UISpeakerButton.h new file mode 100644 index 000000000..f19dff3b2 --- /dev/null +++ b/Classes/LinphoneUI/UISpeakerButton.h @@ -0,0 +1,28 @@ +/* UISpeakerButton.h + * + * Copyright (C) 2011 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 "UIToggleButton.h" + + +@interface UISpeakerButton : UIToggleButton { + +} + +@end diff --git a/Classes/LinphoneUI/UISpeakerButton.m b/Classes/LinphoneUI/UISpeakerButton.m new file mode 100644 index 000000000..adeb0490e --- /dev/null +++ b/Classes/LinphoneUI/UISpeakerButton.m @@ -0,0 +1,64 @@ +/* UISpeakerButton.m + * + * Copyright (C) 2011 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 "UISpeakerButton.h" +#import + +@implementation UISpeakerButton + + +-(void) onOn { + //redirect audio to speaker + UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; + AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute + , sizeof (audioRouteOverride) + , &audioRouteOverride); + +} +-(void) onOff { + UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_None; + AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute + , sizeof (audioRouteOverride) + , &audioRouteOverride); +} +-(bool) isInitialStateOn { + UInt32 audioRouteOverride; + UInt32 size = sizeof (audioRouteOverride); + AudioSessionGetProperty (kAudioSessionProperty_OverrideAudioRoute + , &size + , (void*)(&audioRouteOverride)); + return kAudioSessionOverrideAudioRoute_Speaker == audioRouteOverride; + +} + + +/* + // Only override drawRect: if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + - (void)drawRect:(CGRect)rect { + // Drawing code. + } + */ + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/Classes/LinphoneUI/UIToggleButton.h b/Classes/LinphoneUI/UIToggleButton.h new file mode 100644 index 000000000..ca1f0dfe2 --- /dev/null +++ b/Classes/LinphoneUI/UIToggleButton.h @@ -0,0 +1,41 @@ +/* UIToggleButton.h + * + * Copyright (C) 2011 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 + +@protocol UIToggleButtonDelegate + -(void) onOn; + -(void) onOff; + -(bool) isInitialStateOn; +@end +@interface UIToggleButton : UIButton { +@private + UIImage* mOnImage; + UIImage* mOffImage; + id mActionHandler; + bool mIsOn; + + +} +-(void) initWithOnImage:(UIImage*) onImage offImage:(UIImage*) offImage; +-(bool) reset; +-(bool) isOn; +-(bool) toggle; + +@end diff --git a/Classes/LinphoneUI/UIToggleButton.m b/Classes/LinphoneUI/UIToggleButton.m new file mode 100644 index 000000000..840644f6e --- /dev/null +++ b/Classes/LinphoneUI/UIToggleButton.m @@ -0,0 +1,73 @@ +/* UIToggleButton.m + * + * Copyright (C) 2011 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 "UIToggleButton.h" + + +@implementation UIToggleButton + +-(void) touchUp:(id) sender { + [self toggle]; +} +-(bool) isOn { + return mIsOn; +} +-(bool) toggle { + if (mIsOn) { + [self setImage:mOffImage forState:UIControlStateNormal]; + mIsOn=!mIsOn; + [self onOff]; + } else { + [self setImage:mOnImage forState:UIControlStateNormal]; + mIsOn=!mIsOn; + [self onOn]; + } + return mIsOn; + +} +-(bool) reset { + mIsOn = [self isInitialStateOn]; + [self setImage:mIsOn?mOnImage:mOffImage forState:UIControlStateNormal]; + return mIsOn; +} + +-(void) initWithOnImage:(UIImage*) onImage offImage:(UIImage*) offImage { + mOnImage = [onImage retain]; + mOffImage = [offImage retain]; + mIsOn=false; + [self reset]; + [self addTarget:self action:@selector(touchUp:) forControlEvents:UIControlEventTouchUpInside]; + +} +/* + // Only override drawRect: if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + - (void)drawRect:(CGRect)rect { + // Drawing code. + } + */ + + +- (void)dealloc { + [super dealloc]; + [mOffImage release]; + [mOffImage release]; +} + + +@end diff --git a/Classes/MoreViewController.m b/Classes/MoreViewController.m index 889bf161d..427522974 100644 --- a/Classes/MoreViewController.m +++ b/Classes/MoreViewController.m @@ -19,7 +19,7 @@ #import "MoreViewController.h" #include "ConsoleViewController.h" - +#import "LinphoneManager.h" @implementation MoreViewController @@ -34,6 +34,7 @@ [super viewDidLoad]; [creditText setText: [NSString stringWithFormat:creditText.text,[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]]]; consoleViewController = [[ConsoleViewController alloc] initWithNibName:@"ConsoleViewController" bundle:[NSBundle mainBundle]]; + [[LinphoneManager instance] registerLogView:consoleViewController]; isDebug = [[NSUserDefaults standardUserDefaults] boolForKey:@"debugenable_preference"]; } diff --git a/Classes/PhoneViewController.h b/Classes/PhoneViewController.h index 44cda84b2..a46267089 100644 --- a/Classes/PhoneViewController.h +++ b/Classes/PhoneViewController.h @@ -19,58 +19,47 @@ #import #import #import "linphonecore.h" +#import "UILinphone.h" -@protocol PhoneViewControllerDelegate --(void)setPhoneNumber:(NSString*)number; --(void)setPhoneNumber:(NSString*)number withDisplayName:(NSString*) name; --(void)dismissIncallView; --(void)displayStatus:(NSString*) message; -@end @class IncallViewController; -@interface PhoneViewController : UIViewController { +@interface PhoneViewController : UIViewController { @private //UI definition UITextField* address; - NSString* displayName; + UILabel* mDisplayName; UIView* incallView; - UILabel* callDuration; - UIButton* mute; - UIButton* speaker; + UIDuration* callDuration; + UIMuteButton* mute; + UISpeakerButton* speaker; UILabel* peerLabel; - NSTimer *durationRefreasher; + - UIButton* call; - UIButton* hangup; + UICallButton* call; + UIHangUpButton* hangup; UILabel* status; //key pad - UIButton* one; - UIButton* two; - UIButton* three; - UIButton* four; - UIButton* five; - UIButton* six; - UIButton* seven; - UIButton* eight; - UIButton* nine; - UIButton* star; - UIButton* zero; - UIButton* hash; + UIDigitButton* one; + UIDigitButton* two; + UIDigitButton* three; + UIDigitButton* four; + UIDigitButton* five; + UIDigitButton* six; + UIDigitButton* seven; + UIDigitButton* eight; + UIDigitButton* nine; + UIDigitButton* star; + UIDigitButton* zero; + UIDigitButton* hash; UIButton* back; - bool isMuted; - bool isSpeaker; - - /* - * lib linphone main context - */ - LinphoneCore* mCore; + UITabBarController* myTabBarController; IncallViewController *myIncallViewController; UIActionSheet *mIncomingCallActionSheet; @@ -105,30 +94,9 @@ -/* - * Handle call state change from linphone - */ --(void) onCall:(LinphoneCall*) call StateChanged: (LinphoneCallState) state withMessage: (const char *) message; --(void) setLinphoneCore:(LinphoneCore*) lc; - -/******************** - * UI method handlers - ********************/ --(void)doKeyZeroLongPress; - -//method to handle cal/hangup events -- (IBAction)doAction:(id)sender; - // method to handle keypad event - (IBAction)doKeyPad:(id)sender; -- (IBAction)doKeyPadUp:(id)sender; - --(void) muteAction:(bool) value; --(void) speakerAction:(bool) value; - --(void) dismissAlertDialog:(UIAlertView*)alertView; - - +@property (nonatomic, retain) IBOutlet UITabBarController* myTabBarController; @end diff --git a/Classes/PhoneViewController.m b/Classes/PhoneViewController.m index fee3fd984..4a3b3a987 100644 --- a/Classes/PhoneViewController.m +++ b/Classes/PhoneViewController.m @@ -18,10 +18,10 @@ */ #import "PhoneViewController.h" -#import "osip2/osip.h" +#import "linphoneAppDelegate.h" #import #import - +#import "LinphoneManager.h" @@ -51,206 +51,38 @@ @synthesize hash; @synthesize back; +@synthesize myTabBarController; --(void) erasedisplayName { - if (displayName) { - [displayName release]; - displayName=nil; - } -} --(void)setPhoneNumber:(NSString*)number { - [address setText:number]; - [self erasedisplayName]; -} --(void)setPhoneNumber:(NSString*)number withDisplayName:(NSString*) name { - [self setPhoneNumber:number]; - displayName = name; -} - --(void)dismissIncallView { - [self dismissModalViewControllerAnimated:true]; -} - -//implements call/cancel button behavior --(IBAction) doAction:(id)sender { - - if (sender == call) { - if (!linphone_core_is_network_reachabled(mCore)) { - UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Network Error" - message:@"There is no network connection available, enable WIFI or WWAN prior to place a call" - delegate:nil - cancelButtonTitle:@"Continue" - otherButtonTitles:nil]; - [error show]; - return; - } - if (!linphone_core_in_call(mCore)) { - LinphoneProxyConfig* proxyCfg; - //get default proxy - linphone_core_get_default_proxy(mCore,&proxyCfg); - - if ([address.text length] == 0) return; //just return - if ([address.text hasPrefix:@"sip:"]) { - linphone_core_invite(mCore, [address.text cStringUsingEncoding:[NSString defaultCStringEncoding]]); - } else if ( proxyCfg==nil){ - UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Invalid sip address" - message:@"Either configure a SIP proxy server from settings prior to place a call or use a valid sip address (I.E sip:john@example.net)" - delegate:nil - cancelButtonTitle:@"Continue" - otherButtonTitles:nil]; - [error show]; - - } else { - char normalizedUserName[256]; - NSString* toUserName = [NSString stringWithString:[address text]]; - linphone_proxy_config_normalize_number(proxyCfg,[toUserName cStringUsingEncoding:[NSString defaultCStringEncoding]],normalizedUserName,sizeof(normalizedUserName)); - LinphoneAddress* tmpAddress = linphone_address_new(linphone_core_get_identity(mCore)); - linphone_address_set_username(tmpAddress,normalizedUserName); - linphone_address_set_display_name(tmpAddress,displayName?[displayName cStringUsingEncoding:[NSString defaultCStringEncoding]]:nil); - linphone_core_invite(mCore,linphone_address_as_string(tmpAddress)) ; - linphone_address_destroy(tmpAddress); - } - } else if (linphone_core_inc_invite_pending(mCore)) { - linphone_core_accept_call(mCore,linphone_core_get_current_call(mCore)); - } - - } else if (sender == hangup) { - linphone_core_terminate_call(mCore,linphone_core_get_current_call(mCore)); - } else if (sender == mute) { - [self muteAction:!isMuted]; - - } else if (sender == speaker) { - [self speakerAction:!isSpeaker]; - } -} - //implements keypad behavior -(IBAction) doKeyPad:(id)sender { - if (!linphone_core_in_call(mCore)) { - //outcall behavior - NSString* newAddress = nil; - - if (sender == one) { - newAddress = [address.text stringByAppendingString:@"1"]; - linphone_core_play_dtmf(mCore, '1', -1); - } else if (sender == two) { - newAddress = [address.text stringByAppendingString:@"2"]; - linphone_core_play_dtmf(mCore, '2', -1); - } else if (sender == three) { - newAddress = [address.text stringByAppendingString:@"3"]; - linphone_core_play_dtmf(mCore, '3', -1); - } else if (sender == four) { - newAddress = [address.text stringByAppendingString:@"4"]; - linphone_core_play_dtmf(mCore, '4', -1); - } else if (sender == five) { - newAddress = [address.text stringByAppendingString:@"5"]; - linphone_core_play_dtmf(mCore, '5', -1); - } else if (sender == six) { - newAddress = [address.text stringByAppendingString:@"6"]; - linphone_core_play_dtmf(mCore, '6', -1); - } else if (sender == seven) { - newAddress = [address.text stringByAppendingString:@"7"]; - linphone_core_play_dtmf(mCore, '7', -1); - } else if (sender == eight) { - newAddress = [address.text stringByAppendingString:@"8"]; - linphone_core_play_dtmf(mCore, '8', -1); - } else if (sender == nine) { - newAddress = [address.text stringByAppendingString:@"9"]; - linphone_core_play_dtmf(mCore, '9', -1); - } else if (sender == star) { - newAddress = [address.text stringByAppendingString:@"*"]; - linphone_core_play_dtmf(mCore, '*', -1); - } else if (sender == zero) { - newAddress = [address.text stringByAppendingString:@"0"]; - linphone_core_play_dtmf(mCore, '0', -1); - //start timer for + - [self performSelector:@selector(doKeyZeroLongPress) withObject:nil afterDelay:0.5]; - } else if (sender == hash) { - linphone_core_play_dtmf(mCore, '#', -1); - newAddress = [address.text stringByAppendingString:@"#"]; - } else if (sender == back) { - if ([address.text length] >0) { - newAddress = [address.text substringToIndex: [address.text length]-1]; - } - } else { - ms_message("unknown event from diad pad"); - return; - } - if (newAddress != nil) { - [address setText:newAddress]; - } - } else { - //incall behavior - if (sender == one) { - linphone_core_send_dtmf(mCore,'1'); - } else if (sender == two) { - linphone_core_send_dtmf(mCore,'2'); - } else if (sender == three) { - linphone_core_send_dtmf(mCore,'3'); - } else if (sender == four) { - linphone_core_send_dtmf(mCore,'4'); - } else if (sender == five) { - linphone_core_send_dtmf(mCore,'5'); - } else if (sender == six) { - linphone_core_send_dtmf(mCore,'6'); - } else if (sender == seven) { - linphone_core_send_dtmf(mCore,'7'); - } else if (sender == eight) { - linphone_core_send_dtmf(mCore,'8'); - } else if (sender == nine) { - linphone_core_send_dtmf(mCore,'9'); - } else if (sender == star) { - linphone_core_send_dtmf(mCore,'*'); - } else if (sender == zero) { - linphone_core_send_dtmf(mCore,'0'); - } else if (sender == hash) { - linphone_core_send_dtmf(mCore,'#'); - } else if (sender == hangup) { - linphone_core_terminate_call(mCore,linphone_core_get_current_call(mCore)); - } - } + if (sender == back) { + if ([address.text length] >0) { + NSString* newAddress; + newAddress = [address.text substringToIndex: [address.text length]-1]; + [address setText:newAddress]; + } + } + } -//implements keypad up --(IBAction) doKeyPadUp:(id)sender { - if (sender == zero) { - //cancel timer for + - [NSObject cancelPreviousPerformRequestsWithTarget:self - selector:@selector(doKeyZeroLongPress) - object:nil]; - } - linphone_core_stop_dtmf(mCore); -} --(void)doKeyZeroLongPress { - NSString* newAddress = [[address.text substringToIndex: [address.text length]-1] stringByAppendingString:@"+"]; - [address setText:newAddress]; -} --(void) setLinphoneCore:(LinphoneCore*) lc { - mCore = lc; - [myIncallViewController setLinphoneCore:mCore]; -} --(void)displayStatus:(NSString*) message { - [status setText:message]; - if (myIncallViewController != nil) { - [myIncallViewController displayStatus:message]; - } -} /* // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { - } - - return self; -} -*/ + - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { + } + + return self; + } + */ - (void)viewDidAppear:(BOOL)animated { [[UIApplication sharedApplication] setIdleTimerDisabled:true]; + [mute reset]; + } - (void)viewDidDisappear:(BOOL)animated { [[UIApplication sharedApplication] setIdleTimerDisabled:false]; @@ -260,16 +92,33 @@ // 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 ]; + [two initWithNumber:'2' addressField:address ]; + [three initWithNumber:'3' addressField:address ]; + [four initWithNumber:'4' addressField:address ]; + [five initWithNumber:'5' addressField:address ]; + [six initWithNumber:'6' addressField:address ]; + [seven initWithNumber:'7' addressField:address ]; + [eight initWithNumber:'8' addressField:address ]; + [nine initWithNumber:'9' addressField:address ]; + [star initWithNumber:'*' addressField:address ]; + [hash initWithNumber:'#' addressField:address ]; + [call initWithAddress:address withDisplayName:mDisplayName]; + [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"] ]; + } /* -// Override to allow orientations other than the default portrait orientation. -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - // Return YES for supported orientations - return (interfaceOrientation == UIInterfaceOrientationPortrait); -} -*/ + // Override to allow orientations other than the default portrait orientation. + - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations + return (interfaceOrientation == UIInterfaceOrientationPortrait); + } + */ - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. @@ -287,38 +136,81 @@ - (BOOL)textFieldShouldReturn:(UITextField *)theTextField { if (theTextField == address) { [address resignFirstResponder]; - [self erasedisplayName]; //display name only relefvant + [mDisplayName setText:@""]; //display name only relefvant } return YES; } - --(void) dismissAlertDialog:(UIAlertView*) alertView{ - [alertView dismissWithClickedButtonIndex:0 animated:TRUE]; +-(void) displayDialerFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName { + //cancel local notification, just in case + if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] + && [UIApplication sharedApplication].applicationState == UIApplicationStateBackground ) { + // cancel local notif if needed + [[UIApplication sharedApplication] cancelAllLocalNotifications]; + } else { + if (mIncomingCallActionSheet) { + [mIncomingCallActionSheet dismissWithClickedButtonIndex:1 animated:true]; + mIncomingCallActionSheet=nil; + } + } + + [address setHidden:false]; + if (username) { + [address setText:username]; + } //else keep previous + + [mDisplayName setText:displayName]; + [incallView setHidden:true]; + [call setEnabled:true]; + [hangup setEnabled:false]; + + [callDuration stop]; + + [peerLabel setText:@""]; + + [myTabBarController setSelectedIndex:DIALER_TAB_INDEX]; + +} +-(void) displayCallInProgressFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName { + [hangup setEnabled:true]; + if (displayName && [displayName length]>0) { + [peerLabel setText:displayName]; + } else { + [peerLabel setText:username?username:@""]; + } + if (linphone_call_get_state(linphone_core_get_current_call([LinphoneManager getLc])) == LinphoneCallConnected) { + [callDuration start]; + [callDuration setHidden:false]; + } else { + [callDuration setText:@"Calling..."]; + } + + [address setHidden:true]; + [incallView setHidden:false]; + if (linphone_call_get_dir(linphone_core_get_current_call([LinphoneManager getLc])) == LinphoneCallOutgoing) { + [call setEnabled:false]; + } + } - --(void)updateCallDuration { - int lDuration = linphone_core_get_current_call_duration(mCore); - if (lDuration < 60) { - [callDuration setText:[NSString stringWithFormat: @"%i s", lDuration]]; - } else { - [callDuration setText:[NSString stringWithFormat: @"%i:%i", lDuration/60,lDuration - 60 *(lDuration/60)]]; +-(void) displayIncallFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName { + [self displayCallInProgressFromUI:viewCtrl + forUser:username + withDisplayName:displayName]; +} +//status reporting +-(void) displayStatus:(NSString*) message { + [status setText:message]; + if (myIncallViewController != nil) { + [myIncallViewController displayStatus:message]; } } -- (void)dealloc { - [address dealloc]; - [call dealloc]; - [status dealloc]; - [super dealloc]; -} --(void) newIncomingCall:(NSString*) from { +-(void) displayIncomingCallNotigicationFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName { - //#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000 if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] && [UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { // Create a new notification @@ -326,17 +218,18 @@ if (notif) { notif.repeatInterval = 0; - notif.alertBody =[NSString stringWithFormat:@" %@ is calling you",from]; + notif.alertBody =[NSString stringWithFormat:@" %@ is calling you",username]; notif.alertAction = @"Answer"; notif.soundName = @"oldphone-mono-30s.caf"; [[UIApplication sharedApplication] presentLocalNotificationNow:notif]; } - } else - //#endif - { - mIncomingCallActionSheet = [[UIActionSheet alloc] initWithTitle:[NSString stringWithFormat:@" %@ is calling you",from] - delegate:self cancelButtonTitle:@"Decline" destructiveButtonTitle:@"Answer" otherButtonTitles:nil]; + } else { + mIncomingCallActionSheet = [[UIActionSheet alloc] initWithTitle:[NSString stringWithFormat:@" %@ is calling you",username] + delegate:self + cancelButtonTitle:@"Decline" + destructiveButtonTitle:@"Answer" + otherButtonTitles:nil]; mIncomingCallActionSheet.actionSheetStyle = UIActionSheetStyleDefault; [mIncomingCallActionSheet showInView:self.view]; [mIncomingCallActionSheet release]; @@ -345,159 +238,40 @@ } - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0 ) { - linphone_core_accept_call(mCore,linphone_core_get_current_call(mCore)); + linphone_core_accept_call([LinphoneManager getLc],linphone_core_get_current_call([LinphoneManager getLc])); } else { - linphone_core_terminate_call (mCore,linphone_core_get_current_call(mCore)); + linphone_core_terminate_call ([LinphoneManager getLc],linphone_core_get_current_call([LinphoneManager getLc])); } mIncomingCallActionSheet = nil; } --(void) enterIncallMode { - [hangup setEnabled:true]; - [self muteAction:false]; - // test if speaker must be unactivated after ring tone - if (!isSpeaker) [self speakerAction:false]; - - const LinphoneAddress* callAddress = linphone_call_get_remote_address(linphone_core_get_current_call(mCore)); - const char* callDisplayName = linphone_address_get_display_name(callAddress)?linphone_address_get_display_name(callAddress):""; - if (callDisplayName && callDisplayName[0] != '\000') { - - [peerLabel setText:[NSString stringWithCString:callDisplayName encoding:[NSString defaultCStringEncoding]]]; - } else { - const char* username = linphone_address_get_username(callAddress)!=0?linphone_address_get_username(callAddress):""; - [peerLabel setText:[NSString stringWithCString:username encoding:[NSString defaultCStringEncoding]]]; - } - // start scheduler - durationRefreasher = [NSTimer scheduledTimerWithTimeInterval:1 - target:self - selector:@selector(updateCallDuration) - userInfo:nil - repeats:YES]; - [address setHidden:true]; - [incallView setHidden:false]; - if (linphone_call_get_dir(linphone_core_get_current_call(mCore)) == LinphoneCallOutgoing) { - [call setEnabled:false]; - } - -} --(void) exitIncallMode { - [address setHidden:false]; - [incallView setHidden:true]; - [call setEnabled:true]; - [hangup setEnabled:false]; - - if (durationRefreasher != nil) { - [ durationRefreasher invalidate]; - durationRefreasher=nil; - } - [peerLabel setText:@""]; - [callDuration setText:@""]; +- (void)dealloc { + [address dealloc]; + [ mDisplayName dealloc]; + [incallView dealloc]; + [callDuration dealloc]; + [mute dealloc]; + [speaker dealloc]; + [peerLabel dealloc]; + [call dealloc]; + [hangup dealloc]; + [status dealloc]; + [one dealloc]; + [two dealloc]; + [three dealloc]; + [four dealloc]; + [five dealloc]; + [six dealloc]; + [seven dealloc]; + [eight dealloc]; + [nine dealloc]; + [star dealloc]; + [zero dealloc]; + [hash dealloc]; + [back dealloc]; + [myTabBarController release]; + [myIncallViewController release]; + [super dealloc]; } --(void) onCall:(LinphoneCall*) currentCall StateChanged: (LinphoneCallState) new_state withMessage: (const char *) message { - /* - LinphoneCallIdle, - LinphoneCallIncomingReceived, - LinphoneCallOutgoingInit, - LinphoneCallOutgoingProgress, - LinphoneCallOutgoingRinging, - LinphoneCallOutgoingEarlyMedia, - LinphoneCallConnected, - LinphoneCallStreamsRunning, - LinphoneCallPausing, - LinphoneCallPaused, - LinphoneCallResuming, - LinphoneCallRefered, - LinphoneCallError, - LinphoneCallEnd, - LinphoneCallPausedByRemote - */ - if (new_state != LinphoneCallIncomingReceived) { - if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] - && [UIApplication sharedApplication].applicationState == UIApplicationStateBackground ) { - // cancel local notif if needed - [[UIApplication sharedApplication] cancelAllLocalNotifications]; - } else { - if (mIncomingCallActionSheet) { - [mIncomingCallActionSheet dismissWithClickedButtonIndex:1 animated:true]; - mIncomingCallActionSheet=nil; - } - } - } - switch (new_state) { - case LinphoneCallOutgoingInit: - case LinphoneCallIncomingReceived: { - [self enterIncallMode]; - [self newIncomingCall:[[NSString alloc] initWithCString:linphone_address_get_username(linphone_call_get_remote_address(currentCall))]]; - break; - } - - - case LinphoneCallError: { - /* - NSString* lTitle= state->message!=nil?[NSString stringWithCString:state->message length:strlen(state->message)]: @"Error"; - NSString* lMessage=lTitle; - */ - NSString* lMessage; - NSString* lTitle; - - - lMessage=@"Please make sure your device is connected to the internet and double check your SIP account configuration in the settings."; - - if (message!=nil){ - lMessage=[NSString stringWithFormat : @"%@\nReason was: %s",lMessage, message]; - } - lTitle=@"Call failed"; - - UIAlertView* error = [[UIAlertView alloc] initWithTitle:lTitle - message:lMessage - delegate:nil - cancelButtonTitle:@"Dismiss" - otherButtonTitles:nil]; - [error show]; - [self exitIncallMode]; - //[self performSelector:@selector(dismissAlertDialog:) withObject:error afterDelay:2]; - //[self performSelector:@selector(dismissIncallView) withObject:nil afterDelay:2]; - break; - } - - case LinphoneCallEnd: { - [self exitIncallMode]; - break; - } - default: - break; - } - -} --(void) muteAction:(bool) value { - linphone_core_mute_mic(mCore,value); - if (value) { - [mute setImage:[UIImage imageNamed:@"mic_muted.png"] forState:UIControlStateNormal]; - } else { - [mute setImage:[UIImage imageNamed:@"mic_active.png"] forState:UIControlStateNormal]; - } - isMuted=value; - // swithc buttun state -}; - --(void) speakerAction:(bool) value { - if (value) { - //redirect audio to speaker - UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; - AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute - , sizeof (audioRouteOverride) - , &audioRouteOverride); - [speaker setImage:[UIImage imageNamed:@"Speaker-32-on.png"] forState:UIControlStateNormal]; - } else { - //Cancel audio route redirection - UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_None; - AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute - , sizeof (audioRouteOverride) - , &audioRouteOverride); - [speaker setImage:[UIImage imageNamed:@"Speaker-32-off.png"] forState:UIControlStateNormal]; - } - isSpeaker=value; - -}; @end diff --git a/Classes/PhoneViewController.xib b/Classes/PhoneViewController.xib index 7fb6d985b..03494eccc 100644 --- a/Classes/PhoneViewController.xib +++ b/Classes/PhoneViewController.xib @@ -2,17 +2,17 @@ 784 - 10F569 - 788 - 1038.29 - 461.00 + 10J567 + 823 + 1038.35 + 462.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 117 + 132 YES - + YES @@ -540,15 +540,6 @@ 15 - - - doAction: - - - 7 - - 18 - delegate @@ -661,78 +652,6 @@ 54 - - - doKeyPad: - - - 1 - - 84 - - - - doKeyPad: - - - 1 - - 85 - - - - doKeyPad: - - - 1 - - 86 - - - - doKeyPad: - - - 1 - - 87 - - - - doKeyPad: - - - 1 - - 88 - - - - doKeyPad: - - - 1 - - 89 - - - - doKeyPad: - - - 1 - - 90 - - - - doKeyPad: - - - 1 - - 91 - doKeyPad: @@ -742,42 +661,6 @@ 92 - - - doKeyPad: - - - 1 - - 93 - - - - doKeyPad: - - - 1 - - 94 - - - - doKeyPad: - - - 1 - - 95 - - - - doKeyPadUp: - - - 7 - - 98 - hangup @@ -786,15 +669,6 @@ 109 - - - doAction: - - - 7 - - 110 - incallView @@ -827,15 +701,6 @@ 123 - - - doAction: - - - 7 - - 124 - mute @@ -844,222 +709,6 @@ 125 - - - doAction: - - - 7 - - 126 - - - - doKeyPadUp: - - - 7 - - 127 - - - - doKeyPadUp: - - - 8 - - 128 - - - - doKeyPadUp: - - - 7 - - 129 - - - - doKeyPadUp: - - - 8 - - 130 - - - - doKeyPadUp: - - - 7 - - 131 - - - - doKeyPadUp: - - - 8 - - 132 - - - - doKeyPadUp: - - - 7 - - 133 - - - - doKeyPadUp: - - - 8 - - 134 - - - - doKeyPadUp: - - - 7 - - 135 - - - - doKeyPadUp: - - - 8 - - 136 - - - - doKeyPadUp: - - - 7 - - 137 - - - - doKeyPadUp: - - - 8 - - 138 - - - - doKeyPadUp: - - - 7 - - 139 - - - - doKeyPadUp: - - - 8 - - 140 - - - - doKeyPadUp: - - - 7 - - 141 - - - - doKeyPadUp: - - - 8 - - 142 - - - - doKeyPadUp: - - - 7 - - 143 - - - - doKeyPadUp: - - - 8 - - 144 - - - - doKeyPadUp: - - - 8 - - 145 - - - - doKeyPadUp: - - - 7 - - 146 - - - - doKeyPadUp: - - - 8 - - 147 - - - - doKeyPadUp: - - - 7 - - 148 - - - - doKeyPadUp: - - - 8 - - 149 - @@ -1246,27 +895,44 @@ 1.IBEditorWindowLastContentRect 1.IBPluginDependency 1.IBUserGuides + 107.CustomClassName 107.IBPluginDependency 114.IBEditorWindowLastContentRect 114.IBPluginDependency 114.IBUserGuides 115.IBPluginDependency + 116.CustomClassName 116.IBPluginDependency + 117.CustomClassName 117.IBPluginDependency + 118.CustomClassName 118.IBPluginDependency + 29.CustomClassName 29.IBPluginDependency + 30.CustomClassName 30.IBPluginDependency + 31.CustomClassName 31.IBPluginDependency + 33.CustomClassName 33.IBPluginDependency + 34.CustomClassName 34.IBPluginDependency + 35.CustomClassName 35.IBPluginDependency + 36.CustomClassName 36.IBPluginDependency + 37.CustomClassName 37.IBPluginDependency + 38.CustomClassName 38.IBPluginDependency + 39.CustomClassName 39.IBPluginDependency 4.IBPluginDependency + 40.CustomClassName 40.IBPluginDependency + 41.CustomClassName 41.IBPluginDependency + 5.CustomClassName 5.IBPluginDependency 7.IBPluginDependency 80.IBEditorWindowLastContentRect @@ -1291,6 +957,7 @@ 1 + UIHangUpButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin {{32, 282}, {320, 90}} com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -1303,22 +970,38 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDuration + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UISpeakerButton + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIMuteButton + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDigitButton + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDigitButton + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDigitButton + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDigitButton + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDigitButton + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDigitButton + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDigitButton + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDigitButton + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDigitButton + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDigitButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDigitButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIDigitButton 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 - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UICallButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin {{53, 318}, {320, 480}} @@ -1573,6 +1256,73 @@ + + UICallButton + UIButton + + IBProjectSource + Classes/LinphoneUI/UICallButton.h + + + + UIDigitButton + UIButton + + IBProjectSource + Classes/LinphoneUI/UIDigitButton.h + + + + UIDuration + UILabel + + IBProjectSource + Classes/LinphoneUI/UIDuration.h + + + + UIHangUpButton + UIButton + + IBProjectSource + Classes/LinphoneUI/UIHangUpButton.h + + + + UIMuteButton + UIToggleButton + + IBProjectSource + Classes/LinphoneUI/UIMuteButton.h + + + + UISpeakerButton + UIToggleButton + + IBProjectSource + Classes/LinphoneUI/UISpeakerButton.h + + + + UIToggleButton + UIButton + + mActionHandler + id + + + mActionHandler + + mActionHandler + id + + + + IBProjectSource + Classes/LinphoneUI/UIToggleButton.h + + YES @@ -1720,6 +1470,13 @@ UIKit.framework/Headers/UITextField.h + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIPrintFormatter.h + + UIView @@ -1778,7 +1535,7 @@ com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 @@ -1810,6 +1567,6 @@ {62, 54} - 117 + 132 diff --git a/Classes/linphoneAppDelegate.h b/Classes/linphoneAppDelegate.h index 423c024ab..583b73cbb 100644 --- a/Classes/linphoneAppDelegate.h +++ b/Classes/linphoneAppDelegate.h @@ -20,72 +20,30 @@ #import #import -#import -#include"linphonecore.h" - -@protocol LinphoneTabManagerDelegate - --(void)selectDialerTab; --(void) kickOffNetworkConnection; --(LinphoneCore*) getLinphoneCore; -@end +#define DIALER_TAB_INDEX 1 +#define CONTACTS_TAB_INDEX 2 +#define HISTORY_TAB_INDEX 0 +#define MORE_TAB_INDEX 3 @class ContactPickerDelegate; @class IncallViewController; @class PhoneViewController; @class CallHistoryTableViewController; -@interface linphoneAppDelegate : NSObject { +@interface linphoneAppDelegate : NSObject { UIWindow *window; IBOutlet UITabBarController* myTabBarController; IBOutlet ABPeoplePickerNavigationController* myPeoplePickerController; IBOutlet PhoneViewController* myPhoneViewController; CallHistoryTableViewController* myCallHistoryTableViewController; - ContactPickerDelegate* myContactPickerDelegate; - - bool isDebug; - bool isStarted; - bool backgroundSupported; - bool isbackgroundModeEnabled; - - LinphoneCore* myLinphoneCore; - SCNetworkReachabilityContext proxyReachabilityContext; - SCNetworkReachabilityRef proxyReachability; - CFReadStreamRef mReadStream; - NSTimer* mIterateTimer; - } -/********************************** - * liblinphone initialization method - **********************************/ --(void) startlibLinphone; - -/* - * liblinphone scheduling method; - */ --(void) iterate; - --(void) newIncomingCall:(NSString*) from; - - --(PayloadType*) findPayload:(NSString*)type withRate:(int)rate from:(const MSList*)list; - -/** - * return true if register is activated - */ -void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void * info); - --(void) doRegister; --(void) doLinphoneConfiguration:(NSNotification *)notification; - @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UITabBarController* myTabBarController; @property (nonatomic, retain) ABPeoplePickerNavigationController* myPeoplePickerController; @property (nonatomic, retain) IBOutlet PhoneViewController* myPhoneViewController; -@property(readonly) bool backgroundSupported; @end diff --git a/Classes/linphoneAppDelegate.m b/Classes/linphoneAppDelegate.m index 8ad54a464..7a053512c 100644 --- a/Classes/linphoneAppDelegate.m +++ b/Classes/linphoneAppDelegate.m @@ -21,89 +21,11 @@ #import "linphoneAppDelegate.h" #import "ContactPickerDelegate.h" #import "AddressBook/ABPerson.h" -#import -#import + #import "ConsoleViewController.h" #import "MoreViewController.h" -#include -#include -#include - - -extern void ms_au_register_card(); - -//generic log handler for debug version -void linphone_iphone_log_handler(int lev, const char *fmt, va_list args){ - NSString* format = [[NSString alloc] initWithCString:fmt encoding:[NSString defaultCStringEncoding]]; - NSLogv(format,args); - NSString* formatedString = [[NSString alloc] initWithFormat:format arguments:args]; - [ConsoleViewController addLog:formatedString]; - [format release]; - [formatedString release]; -} - -//Error/warning log handler -void linphone_iphone_log(struct _LinphoneCore * lc, const char * message) { - NSString* log = [NSString stringWithCString:message encoding:[NSString defaultCStringEncoding]]; - NSLog(log); - [ConsoleViewController addLog:log]; -} - -//status -void linphone_iphone_display_status(struct _LinphoneCore * lc, const char * message) { - PhoneViewController* lPhone = ((linphoneAppDelegate*) linphone_core_get_user_data(lc)).myPhoneViewController; - [lPhone displayStatus:[NSString stringWithCString:message encoding:[NSString defaultCStringEncoding]]]; -} - -void linphone_iphone_call_state(LinphoneCore *lc, LinphoneCall* call, LinphoneCallState state,const char* message) { - linphoneAppDelegate* lAppDelegate = (linphoneAppDelegate*) linphone_core_get_user_data(lc); - PhoneViewController* lPhone = lAppDelegate.myPhoneViewController; - [lPhone onCall:call StateChanged:state withMessage:message]; -} - -void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyConfig* cfg, LinphoneRegistrationState state,const char* message) { - linphoneAppDelegate* lAppDelegate = (linphoneAppDelegate*) linphone_core_get_user_data(lc); - 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) { - - - UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Registration failure" - message:lErrorMessage - delegate:lAppDelegate - cancelButtonTitle:@"Continue" - otherButtonTitles:nil ,nil]; - [error show]; - } - - } - -} - - -LinphoneCoreVTable linphonec_vtable = { -.show =NULL, -.call_state_changed =(LinphoneCallStateCb)linphone_iphone_call_state, -.registration_state_changed = linphone_iphone_registration_state, -.notify_recv = NULL, -.new_subscription_request = NULL, -.auth_info_requested = NULL, -.display_status = linphone_iphone_display_status, -.display_message=linphone_iphone_log, -.display_warning=linphone_iphone_log, -.display_url=NULL, -.text_received=NULL, -.dtmf_received=NULL -}; - - +#include "LinphoneManager.h" @implementation linphoneAppDelegate @@ -112,123 +34,29 @@ LinphoneCoreVTable linphonec_vtable = { @synthesize myTabBarController; @synthesize myPeoplePickerController; @synthesize myPhoneViewController; -@synthesize backgroundSupported; + - (void)applicationDidEnterBackground:(UIApplication *)application { - - //#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000 - - struct addrinfo hints; - struct addrinfo *res=NULL; - int err; - - LinphoneProxyConfig* proxyCfg; - LinphoneAddress *addr; - int sipsock = linphone_core_get_sip_socket(myLinphoneCore); - linphone_core_get_default_proxy(myLinphoneCore, &proxyCfg); - - if (isbackgroundModeEnabled && proxyCfg) { - //register - linphone_core_set_network_reachable(myLinphoneCore,false); - linphone_core_iterate(myLinphoneCore); - linphone_core_set_network_reachable(myLinphoneCore,true); - - int i=0; - while (!linphone_proxy_config_is_registered(proxyCfg) && i++<40 ) { - linphone_core_iterate(myLinphoneCore); - usleep(100000); - } - if ([[UIApplication sharedApplication] setKeepAliveTimeout:600/*(NSTimeInterval)linphone_proxy_config_get_expires(proxyCfg)*/ - handler:^{ - ms_warning("keepalive handler"); - //kick up network cnx, just in case - linphone_core_set_network_reachable(myLinphoneCore,false); - linphone_core_iterate(myLinphoneCore); - [self kickOffNetworkConnection]; - linphone_core_set_network_reachable(myLinphoneCore,true); - linphone_core_iterate(myLinphoneCore); - } - ]) { - - - ms_warning("keepalive handler succesfully registered"); - } else { - ms_warning("keepalive handler cannot be registered"); - } - LCSipTransports transportValue; - if (linphone_core_get_sip_transports(myLinphoneCore, &transportValue)) { - ms_error("cannot get current transport"); - } - - if (mReadStream == nil && transportValue.udp_port>0) { //only for udp - const char *port; - addr=linphone_address_new(linphone_proxy_config_get_addr(proxyCfg)); - memset(&hints,0,sizeof(hints)); - hints.ai_family=linphone_core_ipv6_enabled(myLinphoneCore) ? AF_INET6 : AF_INET; - port=linphone_address_get_port(addr); - if (port==NULL) port="5060"; - err=getaddrinfo(linphone_address_get_domain(addr),port,&hints,&res); - if (err!=0){ - ms_error("getaddrinfo() failed for %s: %s",linphone_address_get_domain(addr),gai_strerror(err)); - linphone_address_destroy(addr); - return; - } - err=connect(sipsock,res->ai_addr,res->ai_addrlen); - if (err==-1){ - ms_error("Connect failed: %s",strerror(errno)); - } - freeaddrinfo(res); - - CFStreamCreatePairWithSocket(NULL, (CFSocketNativeHandle)sipsock, &mReadStream,nil); - - if (!CFReadStreamSetProperty(mReadStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP)) { - ms_error("cannot set service type to voip for read stream"); - } - - - if (!CFReadStreamOpen(mReadStream)) { - ms_error("cannot open read stream"); - } - } - } - else { - ms_warning("Entering lite bg mode"); - [self applicationWillTerminate:nil]; - } - - - //#endif - + [[LinphoneManager instance] enterBackgroundMode]; +} +- (void)applicationDidBecomeActive:(UIApplication *)application { + [[LinphoneManager instance] becomeActive]; } - - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ //as defined in PhoneMainView.xib -#define DIALER_TAB_INDEX 1 -#define CONTACTS_TAB_INDEX 2 -#define HISTORY_TAB_INDEX 0 -#define MORE_TAB_INDEX 3 - - UIDevice* device = [UIDevice currentDevice]; - backgroundSupported = false; - if ([device respondsToSelector:@selector(isMultitaskingSupported)]) - backgroundSupported = [device isMultitaskingSupported]; - + //dialer myPhoneViewController = (PhoneViewController*) [myTabBarController.viewControllers objectAtIndex: DIALER_TAB_INDEX]; - + myPhoneViewController.myTabBarController = myTabBarController; //Call history - myCallHistoryTableViewController = [[CallHistoryTableViewController alloc] initWithNibName:@"CallHistoryTableViewController" bundle:[NSBundle mainBundle]]; + myCallHistoryTableViewController = [[CallHistoryTableViewController alloc] initWithNibName:@"CallHistoryTableViewController" + bundle:[NSBundle mainBundle]]; UINavigationController *aCallHistNavigationController = [[UINavigationController alloc] initWithRootViewController:myCallHistoryTableViewController]; aCallHistNavigationController.tabBarItem = [(UIViewController*)[myTabBarController.viewControllers objectAtIndex:HISTORY_TAB_INDEX] tabBarItem]; - [myCallHistoryTableViewController setPhoneControllerDelegate:myPhoneViewController]; - [myCallHistoryTableViewController setLinphoneDelegate:self]; - //people picker delegates myContactPickerDelegate = [[ContactPickerDelegate alloc] init]; - myContactPickerDelegate.phoneControllerDelegate=myPhoneViewController; - myContactPickerDelegate.linphoneDelegate=self; //people picker myPeoplePickerController = [[[ABPeoplePickerNavigationController alloc] init] autorelease]; [myPeoplePickerController setDisplayedProperties:[NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonPhoneProperty]]]; @@ -242,8 +70,6 @@ LinphoneCoreVTable linphonec_vtable = { //copy tab bar item aNavigationController.tabBarItem = [(UIViewController*)[myTabBarController.viewControllers objectAtIndex:MORE_TAB_INDEX] tabBarItem]; - - //insert contact controller NSMutableArray* newArray = [NSMutableArray arrayWithArray:self.myTabBarController.viewControllers]; [newArray replaceObjectAtIndex:CONTACTS_TAB_INDEX withObject:myPeoplePickerController]; @@ -257,67 +83,16 @@ LinphoneCoreVTable linphonec_vtable = { [window makeKeyAndVisible]; - [self startlibLinphone]; - - [myCallHistoryTableViewController setLinphoneCore: myLinphoneCore]; - - [myPhoneViewController setLinphoneCore: myLinphoneCore]; + [[LinphoneManager instance] setUiController:myPhoneViewController]; + [[LinphoneManager instance] startLibLinphone]; [ [UIDevice currentDevice] setProximityMonitoringEnabled:true]; - + return YES; } --(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]; -} --(void) runNetworkConnection { - CFWriteStreamRef writeStream; - CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"192.168.0.200"/*"linphone.org"*/, 15000, nil, &writeStream); - CFWriteStreamOpen (writeStream); - const char* buff="hello"; - CFWriteStreamWrite (writeStream,(const UInt8*)buff,strlen(buff)); - CFWriteStreamClose (writeStream); -} -- (void)applicationDidBecomeActive:(UIApplication *)application { - - if (myLinphoneCore == nil) { - //back from standby and background mode is disabled - [self startlibLinphone]; - - [myCallHistoryTableViewController setLinphoneCore: myLinphoneCore]; - - [myPhoneViewController setLinphoneCore: myLinphoneCore]; - } - if (isStarted) { - ms_message("becomming active, make sure we are registered"); - [self doRegister]; - } else { - isStarted=true; - } - if (mReadStream !=nil) { - - //unconnect - int socket = linphone_core_get_sip_socket(myLinphoneCore); - struct sockaddr hints; - memset(&hints,0,sizeof(hints)); - hints.sa_family=AF_UNSPEC; - connect(socket,&hints,sizeof(hints)); - CFReadStreamClose(mReadStream); - CFRelease(mReadStream); - mReadStream=nil; - } -} - --(void)selectDialerTab { - [myTabBarController setSelectedIndex:DIALER_TAB_INDEX]; -} - (void)applicationWillTerminate:(UIApplication *)application { - [mIterateTimer invalidate]; - linphone_core_destroy(myLinphoneCore); - myLinphoneCore = nil; } - (void)dealloc { @@ -326,265 +101,6 @@ LinphoneCoreVTable linphonec_vtable = { [super dealloc]; } -extern void libmsilbc_init(); - -/************* - *lib linphone init method - */ --(void)startlibLinphone { - - //get default config from bundle - NSBundle* myBundle = [NSBundle mainBundle]; - NSString* factoryConfig = [myBundle pathForResource:@"linphonerc"ofType:nil] ; - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - NSString *confiFileName = [[paths objectAtIndex:0] stringByAppendingString:@"/.linphonerc"]; - ; - signal(SIGPIPE, SIG_IGN); - //log management - isDebug = [[NSUserDefaults standardUserDefaults] boolForKey:@"debugenable_preference"]; - if (isDebug) { - //redirect all traces to the iphone log framework - linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler); - } - else { - linphone_core_disable_logs(); - } - - libmsilbc_init(); - - /* - * Initialize linphone core - */ - - myLinphoneCore = linphone_core_new (&linphonec_vtable - , [confiFileName cStringUsingEncoding:[NSString defaultCStringEncoding]] - , [factoryConfig cStringUsingEncoding:[NSString defaultCStringEncoding]] - ,self); - - [ self doLinphoneConfiguration:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(doLinphoneConfiguration:) - name:NSUserDefaultsDidChangeNotification object:nil]; - - - // start scheduler - mIterateTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 - target:self - selector:@selector(iterate) - userInfo:nil - repeats:YES]; - //init audio session - AVAudioSession *audioSession = [AVAudioSession sharedInstance]; - BOOL bAudioInputAvailable= [audioSession inputIsAvailable]; - - if(!bAudioInputAvailable){ - UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"No microphone" - message:@"You need to plug a microphone to your device to use this application." - delegate:self - cancelButtonTitle:@"Ok" - otherButtonTitles:nil ,nil]; - [error show]; - } - - - -} --(void) doLinphoneConfiguration:(NSNotification *)notification { - ms_message("Configuring Linphone"); - - isDebug = [[NSUserDefaults standardUserDefaults] boolForKey:@"debugenable_preference"]; - if (isDebug) { - //redirect all traces to the iphone log framework - linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler); - } - else { - linphone_core_disable_logs(); - } - NSString* transport = [[NSUserDefaults standardUserDefaults] stringForKey:@"transport_preference"]; - - //initial state is network off should be done as soon as possible - linphone_core_set_network_reachable(myLinphoneCore,false); - - LCSipTransports transportValue; - if (transport!=nil) { - if (linphone_core_get_sip_transports(myLinphoneCore, &transportValue)) { - ms_error("cannot get current transport"); - } - if ([transport isEqualToString:@"tcp"]) { - if (transportValue.tcp_port == 0) transportValue.tcp_port=transportValue.udp_port; - transportValue.udp_port=0; - } else if ([transport isEqualToString:@"udp"]){ - if (transportValue.udp_port == 0) transportValue.udp_port=transportValue.tcp_port; - transportValue.tcp_port=0; - } else { - ms_error("unexpected trasnport [%s]",[transport cStringUsingEncoding:[NSString defaultCStringEncoding]]); - } - if (linphone_core_set_sip_transports(myLinphoneCore, &transportValue)) { - ms_error("cannot set transport"); - } - } - - - - - // Set audio assets - NSBundle* myBundle = [NSBundle mainBundle]; - const char* lRing = [[myBundle pathForResource:@"oldphone-mono"ofType:@"wav"] cStringUsingEncoding:[NSString defaultCStringEncoding]]; - linphone_core_set_ring(myLinphoneCore, lRing ); - const char* lRingBack = [[myBundle pathForResource:@"ringback"ofType:@"wav"] cStringUsingEncoding:[NSString defaultCStringEncoding]]; - linphone_core_set_ringback(myLinphoneCore, lRingBack); - - - - - //configure sip account - - //madatory parameters - - NSString* username = [[NSUserDefaults standardUserDefaults] stringForKey:@"username_preference"]; - NSString* domain = [[NSUserDefaults standardUserDefaults] stringForKey:@"domain_preference"]; - NSString* accountPassword = [[NSUserDefaults standardUserDefaults] stringForKey:@"password_preference"]; - bool configCheckDisable = [[NSUserDefaults standardUserDefaults] boolForKey:@"check_config_disable_preference"]; - bool isOutboundProxy= [[NSUserDefaults standardUserDefaults] boolForKey:@"outbound_proxy_preference"]; - - - //clear auth info list - linphone_core_clear_all_auth_info(myLinphoneCore); - //clear existing proxy config - linphone_core_clear_proxy_config(myLinphoneCore); - if (proxyReachability !=nil) { - SCNetworkReachabilityUnscheduleFromRunLoop(proxyReachability,CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); - } - if (username && [username length] >0 && domain && [domain length]>0) { - - - const char* identity = [[NSString stringWithFormat:@"sip:%@@%@",username,domain] cStringUsingEncoding:[NSString defaultCStringEncoding]]; - const char* password = [accountPassword cStringUsingEncoding:[NSString defaultCStringEncoding]]; - - NSString* proxyAddress = [[NSUserDefaults standardUserDefaults] stringForKey:@"proxy_preference"]; - if ((!proxyAddress | [proxyAddress length] <1 ) && domain) { - proxyAddress = [NSString stringWithFormat:@"sip:%@",domain] ; - } else { - proxyAddress = [NSString stringWithFormat:@"sip:%@",proxyAddress] ; - } - - const char* proxy = [proxyAddress cStringUsingEncoding:[NSString defaultCStringEncoding]]; - - NSString* prefix = [[NSUserDefaults standardUserDefaults] stringForKey:@"prefix_preference"]; - //possible valid config detected - LinphoneProxyConfig* proxyCfg; - proxyCfg = linphone_proxy_config_new(); - - // add username password - LinphoneAddress *from = linphone_address_new(identity); - LinphoneAuthInfo *info; - if (from !=0){ - info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,NULL,NULL); - linphone_core_add_auth_info(myLinphoneCore,info); - } - linphone_address_destroy(from); - - // configure proxy entries - linphone_proxy_config_set_identity(proxyCfg,identity); - linphone_proxy_config_set_server_addr(proxyCfg,proxy); - linphone_proxy_config_enable_register(proxyCfg,true); - - if (isOutboundProxy) - linphone_proxy_config_set_route(proxyCfg,proxy); - - if ([prefix length]>0) { - linphone_proxy_config_set_dial_prefix(proxyCfg, [prefix cStringUsingEncoding:[NSString defaultCStringEncoding]]); - } - linphone_proxy_config_set_dial_escape_plus(proxyCfg,TRUE); - - linphone_core_add_proxy_config(myLinphoneCore,proxyCfg); - //set to default proxy - linphone_core_set_default_proxy(myLinphoneCore,proxyCfg); - - LinphoneAddress* addr=linphone_address_new(linphone_proxy_config_get_addr(proxyCfg)); - proxyReachability=SCNetworkReachabilityCreateWithName(nil, linphone_address_get_domain(addr)); - - - - [self doRegister]; - } else { - if (configCheckDisable == false) { - UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Warning" - message:@"It seems you have not configured any proxy server from settings" - delegate:self - cancelButtonTitle:@"Continue" - otherButtonTitles:@"Never remind",nil]; - [error show]; - } - - proxyReachability=SCNetworkReachabilityCreateWithName(nil, "linphone.org"); - } - proxyReachabilityContext.info=self; - SCNetworkReachabilitySetCallback(proxyReachability, (SCNetworkReachabilityCallBack)networkReachabilityCallBack,&proxyReachabilityContext); - SCNetworkReachabilityScheduleWithRunLoop(proxyReachability, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); - - //Configure Codecs - - PayloadType *pt; - //get codecs from linphonerc - const MSList *audioCodecs=linphone_core_get_audio_codecs(myLinphoneCore); - const MSList *elem; - //disable all codecs - for (elem=audioCodecs;elem!=NULL;elem=elem->next){ - pt=(PayloadType*)elem->data; - linphone_core_enable_payload_type(myLinphoneCore,pt,FALSE); - } - - //read codecs from setting bundle and enable them one by one - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"speex_32k_preference"]) { - if(pt = [self findPayload:@"speex"withRate:32000 from:audioCodecs]) { - linphone_core_enable_payload_type(myLinphoneCore,pt, TRUE); - } - } - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"speex_16k_preference"]) { - if(pt = [self findPayload:@"speex"withRate:16000 from:audioCodecs]) { - linphone_core_enable_payload_type(myLinphoneCore,pt, TRUE); - } - } - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"speex_8k_preference"]) { - if(pt = [self findPayload:@"speex"withRate:8000 from:audioCodecs]) { - linphone_core_enable_payload_type(myLinphoneCore,pt, TRUE); - } - } - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"gsm_22k_preference"]) { - if(pt = [self findPayload:@"GSM"withRate:22050 from:audioCodecs]) { - linphone_core_enable_payload_type(myLinphoneCore,pt, TRUE); - } - } - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"gsm_11k_preference"]) { - if(pt = [self findPayload:@"GSM"withRate:11025 from:audioCodecs]) { - linphone_core_enable_payload_type(myLinphoneCore,pt, TRUE); - } - } - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"gsm_8k_preference"]) { - if(pt = [self findPayload:@"GSM"withRate:8000 from:audioCodecs]) { - linphone_core_enable_payload_type(myLinphoneCore,pt, TRUE); - } - } - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"ilbc_preference"]) { - if(pt = [self findPayload:@"iLBC"withRate:8000 from:audioCodecs]) { - linphone_core_enable_payload_type(myLinphoneCore,pt, TRUE); - } - } - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"pcmu_preference"]) { - if(pt = [self findPayload:@"PCMU"withRate:8000 from:audioCodecs]) { - linphone_core_enable_payload_type(myLinphoneCore,pt, TRUE); - } - } - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"pcma_preference"]) { - if(pt = [self findPayload:@"PCMA"withRate:8000 from:audioCodecs]) { - linphone_core_enable_payload_type(myLinphoneCore,pt, TRUE); - } - } - - isbackgroundModeEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"backgroundmode_preference"]; - -} // no proxy configured alert - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { @@ -595,52 +111,10 @@ extern void libmsilbc_init(); - - - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { - linphone_core_accept_call(myLinphoneCore,linphone_core_get_current_call(myLinphoneCore)); -} -//scheduling loop --(void) iterate { - linphone_core_iterate(myLinphoneCore); + linphone_core_accept_call([LinphoneManager getLc],linphone_core_get_current_call([LinphoneManager getLc])); } --(PayloadType*) findPayload:(NSString*)type withRate:(int)rate from:(const MSList*)list { - const MSList *elem; - for(elem=list;elem!=NULL;elem=elem->next){ - PayloadType *pt=(PayloadType*)elem->data; - if ([type isEqualToString:[NSString stringWithCString:payload_type_get_mime(pt) encoding:[NSString defaultCStringEncoding]]] && rate==pt->clock_rate) { - return pt; - } - } - return nil; - -} - -void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void * info) { - id linphoneDelegate=info; - LinphoneCore* lc = [linphoneDelegate getLinphoneCore]; - bool result = false; - ms_message("Network connection flag [%x]",flags); - if (lc != nil) { - if ((flags == 0) | (flags & (kSCNetworkReachabilityFlagsConnectionRequired |kSCNetworkReachabilityFlagsConnectionOnTraffic))) { - [linphoneDelegate kickOffNetworkConnection]; - linphone_core_set_network_reachable(lc,false); - } else { - linphone_core_set_network_reachable(lc,true); - } - - } - return result; -} --(LinphoneCore*) getLinphoneCore { - return myLinphoneCore; -} --(void) doRegister { - SCNetworkReachabilityFlags reachabilityFlags; - SCNetworkReachabilityGetFlags (proxyReachability,&reachabilityFlags); - networkReachabilityCallBack(proxyReachability,reachabilityFlags,self); -} @end diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 95dc028f8..4d4e49b9c 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -7,7 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - 1D3623260D0F684500981E51 /* linphoneAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* linphoneAppDelegate.m */; }; + 1D3623260D0F684500981E51 /* LinphoneAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* LinphoneAppDelegate.m */; }; 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; @@ -19,11 +19,16 @@ 220FAD3810765B400068D98F /* libspeex.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 220FAD2F10765B400068D98F /* libspeex.a */; }; 220FAD3910765B400068D98F /* libspeexdsp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 220FAD3010765B400068D98F /* libspeexdsp.a */; }; 220FAE4B10767A6A0068D98F /* PhoneMainView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 220FAE4A10767A6A0068D98F /* PhoneMainView.xib */; }; + 2214EB7A12F846B1002A5394 /* UICallButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 2214EB7912F846B1002A5394 /* UICallButton.m */; }; + 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 */; }; 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 */; }; 22226C191181986A000CA27B /* dialer-orange.png in Resources */ = {isa = PBXBuildFile; fileRef = 22226C171181986A000CA27B /* dialer-orange.png */; }; 22226C1D11819B34000CA27B /* history-orange.png in Resources */ = {isa = PBXBuildFile; fileRef = 22226C1C11819B34000CA27B /* history-orange.png */; }; + 222A483412F7176F0075F07F /* IncallViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 222A483112F7176F0075F07F /* IncallViewController.xib */; }; 223148E41178A08200637D6A /* libilbc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 223148E31178A08200637D6A /* libilbc.a */; }; 223148E61178A09900637D6A /* libmsilbc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 223148E51178A09900637D6A /* libmsilbc.a */; }; 2237D4091084D7A9001383EE /* oldphone-mono.wav in Resources */ = {isa = PBXBuildFile; fileRef = 2237D4081084D7A9001383EE /* oldphone-mono.wav */; }; @@ -36,6 +41,8 @@ 2245671D107699F700F10948 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 2245671C107699F700F10948 /* Settings.bundle */; }; 224567C2107B968500F10948 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 224567C1107B968500F10948 /* AVFoundation.framework */; }; 2245F78A1201D38000C4179D /* MoreViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 22E0A81B111C44E100B04932 /* MoreViewController.xib */; }; + 2248E90E12F7E4CF00220D9C /* UIDigitButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 2248E90D12F7E4CF00220D9C /* UIDigitButton.m */; }; + 2248E99F12F801C200220D9C /* LinphoneManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2248E99E12F801C200220D9C /* LinphoneManager.m */; }; 2252941412F6DAA400DD9BFB /* libmediastreamer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 220FAD2B10765B400068D98F /* libmediastreamer.a */; }; 225CB2EA11ABB51000628906 /* clavier-01-106px.png in Resources */ = {isa = PBXBuildFile; fileRef = 225CB2E811ABB51000628906 /* clavier-01-106px.png */; }; 225CB2EB11ABB51000628906 /* clavier-01-108px.png in Resources */ = {isa = PBXBuildFile; fileRef = 225CB2E911ABB51000628906 /* clavier-01-108px.png */; }; @@ -48,6 +55,8 @@ 227BCDC210D4004600FBFD76 /* CallHistoryTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 227BCDC010D4004600FBFD76 /* CallHistoryTableViewController.m */; }; 227BCDC310D4004600FBFD76 /* CallHistoryTableViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 227BCDC110D4004600FBFD76 /* CallHistoryTableViewController.xib */; }; 228697C411AC29B800E9E0CA /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 228697C311AC29B800E9E0CA /* CFNetwork.framework */; }; + 22968A5F12F875C600588287 /* UISpeakerButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 22968A5E12F875C600588287 /* UISpeakerButton.m */; }; + 22968A8812F87C2000588287 /* UIDuration.m in Sources */ = {isa = PBXBuildFile; fileRef = 22968A8712F87C2000588287 /* UIDuration.m */; }; 22A10F3B11F8960300373793 /* libortp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 220FAD2C10765B400068D98F /* libortp.a */; }; 22B5EFA310CE50BD00777D97 /* AddressBookUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22B5EFA210CE50BD00777D97 /* AddressBookUI.framework */; }; 22B5EFE510CE5E5800777D97 /* ContactPickerDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 22B5EFE410CE5E5800777D97 /* ContactPickerDelegate.m */; }; @@ -89,8 +98,8 @@ /* Begin PBXFileReference section */ 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 1D3623240D0F684500981E51 /* linphoneAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = linphoneAppDelegate.h; sourceTree = ""; }; - 1D3623250D0F684500981E51 /* linphoneAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = linphoneAppDelegate.m; sourceTree = ""; }; + 1D3623240D0F684500981E51 /* LinphoneAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinphoneAppDelegate.h; sourceTree = ""; }; + 1D3623250D0F684500981E51 /* LinphoneAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LinphoneAppDelegate.m; sourceTree = ""; }; 1D6058910D05DD3D006BFB54 /* linphone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = linphone.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 22058C70116E305000B08DDD /* icone-linphone-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icone-linphone-57.png"; path = "Resources/icone-linphone-57.png"; sourceTree = ""; }; @@ -210,11 +219,25 @@ 220FAD2F10765B400068D98F /* libspeex.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libspeex.a; path = "liblinphone-sdk/apple-darwin/lib/libspeex.a"; sourceTree = ""; }; 220FAD3010765B400068D98F /* libspeexdsp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libspeexdsp.a; path = "liblinphone-sdk/apple-darwin/lib/libspeexdsp.a"; sourceTree = ""; }; 220FAE4A10767A6A0068D98F /* PhoneMainView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PhoneMainView.xib; sourceTree = ""; }; + 2214EB7812F846B1002A5394 /* UICallButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICallButton.h; sourceTree = ""; }; + 2214EB7912F846B1002A5394 /* UICallButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICallButton.m; sourceTree = ""; }; + 2214EB8712F84EBB002A5394 /* UIHangUpButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIHangUpButton.h; sourceTree = ""; }; + 2214EB8812F84EBB002A5394 /* UIHangUpButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIHangUpButton.m; sourceTree = ""; }; + 2214EB8A12F84FE9002A5394 /* UILinphone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILinphone.h; sourceTree = ""; }; + 2214EBD812F8558F002A5394 /* UIToggleButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIToggleButton.h; sourceTree = ""; }; + 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 = ""; }; + 2218A5CE12F973450088A667 /* LogView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogView.h; 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 = ""; }; 22226C171181986A000CA27B /* dialer-orange.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "dialer-orange.png"; path = "liblinphone-sdk/apple-darwin/share/pixmaps/linphone/dialer-orange.png"; sourceTree = ""; }; 22226C1C11819B34000CA27B /* history-orange.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "history-orange.png"; path = "liblinphone-sdk/apple-darwin/share/pixmaps/linphone/history-orange.png"; sourceTree = ""; }; + 222A483112F7176F0075F07F /* IncallViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IncallViewController.xib; sourceTree = ""; }; + 222A483212F7176F0075F07F /* IncallViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IncallViewController.m; sourceTree = ""; }; + 222A483312F7176F0075F07F /* IncallViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IncallViewController.h; sourceTree = ""; }; 223148E31178A08200637D6A /* libilbc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libilbc.a; path = "liblinphone-sdk/apple-darwin/lib/libilbc.a"; sourceTree = ""; }; 223148E51178A09900637D6A /* libmsilbc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmsilbc.a; path = "liblinphone-sdk/apple-darwin/lib/mediastreamer/plugins/libmsilbc.a"; sourceTree = ""; }; 2237D4081084D7A9001383EE /* oldphone-mono.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = "oldphone-mono.wav"; path = "liblinphone-sdk/apple-darwin/share/sounds/linphone/rings/oldphone-mono.wav"; sourceTree = ""; }; @@ -227,6 +250,10 @@ 2242E312125235120061DDCE /* oldphone-mono-30s.caf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "oldphone-mono-30s.caf"; path = "liblinphone-sdk/apple-darwin/share/sounds/linphone/rings/oldphone-mono-30s.caf"; sourceTree = ""; }; 2245671C107699F700F10948 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = ""; }; 224567C1107B968500F10948 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; + 2248E90C12F7E4CF00220D9C /* UIDigitButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIDigitButton.h; sourceTree = ""; }; + 2248E90D12F7E4CF00220D9C /* UIDigitButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIDigitButton.m; sourceTree = ""; }; + 2248E99D12F801C200220D9C /* LinphoneManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinphoneManager.h; sourceTree = ""; }; + 2248E99E12F801C200220D9C /* LinphoneManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LinphoneManager.m; sourceTree = ""; }; 2258633C11410BAC00C5A737 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; 225CB2E811ABB51000628906 /* clavier-01-106px.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "clavier-01-106px.png"; path = "Resources/clavier-01-106px.png"; sourceTree = ""; }; 225CB2E911ABB51000628906 /* clavier-01-108px.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "clavier-01-108px.png"; path = "Resources/clavier-01-108px.png"; sourceTree = ""; }; @@ -242,6 +269,10 @@ 227BCDC010D4004600FBFD76 /* CallHistoryTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CallHistoryTableViewController.m; sourceTree = ""; }; 227BCDC110D4004600FBFD76 /* CallHistoryTableViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CallHistoryTableViewController.xib; sourceTree = ""; }; 228697C311AC29B800E9E0CA /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; + 22968A5D12F875C600588287 /* UISpeakerButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UISpeakerButton.h; sourceTree = ""; }; + 22968A5E12F875C600588287 /* UISpeakerButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UISpeakerButton.m; sourceTree = ""; }; + 22968A8612F87C2000588287 /* UIDuration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIDuration.h; sourceTree = ""; }; + 22968A8712F87C2000588287 /* UIDuration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIDuration.m; sourceTree = ""; }; 22A10D9E11F88C1F00373793 /* liblinphone.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = liblinphone.xcodeproj; path = submodules/liblinphone.xcodeproj; sourceTree = ""; }; 22B5EFA210CE50BD00777D97 /* AddressBookUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBookUI.framework; path = System/Library/Frameworks/AddressBookUI.framework; sourceTree = SDKROOT; }; 22B5EFE310CE5E5800777D97 /* ContactPickerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactPickerDelegate.h; sourceTree = ""; }; @@ -302,14 +333,18 @@ 080E96DDFE201D6D7F000001 /* Classes */ = { isa = PBXGroup; children = ( + 2214EB7012F84668002A5394 /* LinphoneUI */, + 222A483112F7176F0075F07F /* IncallViewController.xib */, + 222A483212F7176F0075F07F /* IncallViewController.m */, + 222A483312F7176F0075F07F /* IncallViewController.h */, 22E0A81B111C44E100B04932 /* MoreViewController.xib */, 22E0A81C111C44E100B04932 /* MoreViewController.m */, 22E0A81D111C44E100B04932 /* MoreViewController.h */, 22E0A81E111C44E100B04932 /* ConsoleViewController.xib */, 22E0A81F111C44E100B04932 /* ConsoleViewController.m */, 22E0A820111C44E100B04932 /* ConsoleViewController.h */, - 1D3623240D0F684500981E51 /* linphoneAppDelegate.h */, - 1D3623250D0F684500981E51 /* linphoneAppDelegate.m */, + 1D3623240D0F684500981E51 /* LinphoneAppDelegate.h */, + 1D3623250D0F684500981E51 /* LinphoneAppDelegate.m */, 22F2508B107141E100AC9B3F /* PhoneViewController.h */, 22F2508C107141E100AC9B3F /* PhoneViewController.m */, 22F2508D107141E100AC9B3F /* PhoneViewController.xib */, @@ -519,6 +554,32 @@ path = speex; sourceTree = ""; }; + 2214EB7012F84668002A5394 /* LinphoneUI */ = { + isa = PBXGroup; + children = ( + 2248E90C12F7E4CF00220D9C /* UIDigitButton.h */, + 2248E90D12F7E4CF00220D9C /* UIDigitButton.m */, + 2248E99D12F801C200220D9C /* LinphoneManager.h */, + 2248E99E12F801C200220D9C /* LinphoneManager.m */, + 2214EB7812F846B1002A5394 /* UICallButton.h */, + 2214EB7912F846B1002A5394 /* UICallButton.m */, + 2214EB8712F84EBB002A5394 /* UIHangUpButton.h */, + 2214EB8812F84EBB002A5394 /* UIHangUpButton.m */, + 2214EB8A12F84FE9002A5394 /* UILinphone.h */, + 2214EBD812F8558F002A5394 /* UIToggleButton.h */, + 2214EBD912F8558F002A5394 /* UIToggleButton.m */, + 2214EBF112F86360002A5394 /* UIMuteButton.h */, + 2214EBF212F86360002A5394 /* UIMuteButton.m */, + 22968A5D12F875C600588287 /* UISpeakerButton.h */, + 22968A5E12F875C600588287 /* UISpeakerButton.m */, + 22968A8612F87C2000588287 /* UIDuration.h */, + 22968A8712F87C2000588287 /* UIDuration.m */, + 2218A5C412F9597B0088A667 /* LinphoneUIControler.h */, + 2218A5CE12F973450088A667 /* LogView.h */, + ); + path = LinphoneUI; + sourceTree = ""; + }; 22A10D9F11F88C1F00373793 /* Products */ = { isa = PBXGroup; children = ( @@ -705,6 +766,7 @@ 225CB2FA11ABB76400628906 /* linphone-banner.png in Resources */, 2245F78A1201D38000C4179D /* MoreViewController.xib in Resources */, 2242E313125235120061DDCE /* oldphone-mono-30s.caf in Resources */, + 222A483412F7176F0075F07F /* IncallViewController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -716,13 +778,21 @@ buildActionMask = 2147483647; files = ( 1D60589B0D05DD56006BFB54 /* main.m in Sources */, - 1D3623260D0F684500981E51 /* linphoneAppDelegate.m in Sources */, + 1D3623260D0F684500981E51 /* LinphoneAppDelegate.m in Sources */, 22F2508E107141E100AC9B3F /* PhoneViewController.m in Sources */, 22B5EFE510CE5E5800777D97 /* ContactPickerDelegate.m in Sources */, 227BCDC210D4004600FBFD76 /* CallHistoryTableViewController.m in Sources */, 2242D9C910D691F900E9963F /* GenericTabViewController.m in Sources */, 22E0A822111C44E100B04932 /* MoreViewController.m in Sources */, 22E0A824111C44E100B04932 /* ConsoleViewController.m in Sources */, + 2248E90E12F7E4CF00220D9C /* UIDigitButton.m in Sources */, + 2248E99F12F801C200220D9C /* LinphoneManager.m in Sources */, + 2214EB7A12F846B1002A5394 /* UICallButton.m in Sources */, + 2214EB8912F84EBB002A5394 /* UIHangUpButton.m in Sources */, + 2214EBDA12F8558F002A5394 /* UIToggleButton.m in Sources */, + 2214EBF312F86360002A5394 /* UIMuteButton.m in Sources */, + 22968A5F12F875C600588287 /* UISpeakerButton.m in Sources */, + 22968A8812F87C2000588287 /* UIDuration.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/submodules/liblinphone.xcodeproj/project.pbxproj b/submodules/liblinphone.xcodeproj/project.pbxproj index 8b18aa585..bf225895d 100644 --- a/submodules/liblinphone.xcodeproj/project.pbxproj +++ b/submodules/liblinphone.xcodeproj/project.pbxproj @@ -980,6 +980,7 @@ OTHER_LDFLAGS = "-ObjC"; PREBINDING = NO; SDKROOT = iphoneos; + VALID_ARCHS = "armv6 armv7"; }; name = Debug; }; @@ -1019,6 +1020,7 @@ OTHER_LDFLAGS = "-ObjC"; PREBINDING = NO; SDKROOT = iphoneos; + VALID_ARCHS = "armv6 armv7"; }; name = Release; }; diff --git a/submodules/linphone b/submodules/linphone index fd5e9b931..f89550038 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit fd5e9b931875505c10be591afa83a11b4b813b40 +Subproject commit f89550038a73df8d7ded83252401fea09afd65ba