new UI architecture

This commit is contained in:
Jehan Monnier 2011-02-03 16:16:36 +01:00
parent 0c17f3a24f
commit d0a0311b94
38 changed files with 3963 additions and 1433 deletions

View file

@ -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];
}

View file

@ -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 <UIKit/UIKit.h>
#import "LogView.h"
@protocol LogView
+(void) addLog:(NSString*) log;
@end
@interface ConsoleViewController : UIViewController <LogView> {
UITextView* logs;

View file

@ -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];

View file

@ -23,11 +23,8 @@
@interface ContactPickerDelegate : NSObject<ABPeoplePickerNavigationControllerDelegate> {
id<PhoneViewControllerDelegate> phoneControllerDelegate;
id<LinphoneTabManagerDelegate> linphoneDelegate;
}
@property (nonatomic, retain) id<PhoneViewControllerDelegate> phoneControllerDelegate;
@property (nonatomic, retain) id<LinphoneTabManagerDelegate> linphoneDelegate;
@end

View file

@ -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

View file

@ -24,13 +24,8 @@
@interface GenericTabViewController : UITableViewController {
LinphoneCore* myLinphoneCore;
id<PhoneViewControllerDelegate> phoneControllerDelegate;
id<LinphoneTabManagerDelegate> linphoneDelegate;
IBOutlet UIView* header;
}
-(void) setLinphoneCore:(LinphoneCore*) lc;
@property (nonatomic, retain) id<PhoneViewControllerDelegate> phoneControllerDelegate;
@property (nonatomic, retain) id<LinphoneTabManagerDelegate> linphoneDelegate;
@property (nonatomic, retain) IBOutlet UIView* header;
@end

View file

@ -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 {

View file

@ -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 <UIKit/UIKit.h>
#import "linphonecore.h"
#import "PhoneViewController.h"
#import <AddressBookUI/ABPeoplePickerNavigationController.h>
@interface IncallViewController : UIViewController <ABPeoplePickerNavigationControllerDelegate> {
LinphoneCore* myLinphoneCore;
id<PhoneViewControllerDelegate> 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<PhoneViewControllerDelegate> phoneviewDelegate;
@end

View file

@ -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 <AudioToolbox/AudioToolbox.h>
#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

File diff suppressed because it is too large Load diff

View file

@ -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 <Foundation/Foundation.h>
#import <SystemConfiguration/SCNetworkReachability.h>
#include "linphonecore.h"
#import "LogView.h"
#import "LinphoneUIControler.h"
@interface LinphoneManager : NSObject {
@private
SCNetworkReachabilityContext proxyReachabilityContext;
SCNetworkReachabilityRef proxyReachability;
CFReadStreamRef mReadStream;
NSTimer* mIterateTimer;
id<LogView> mLogView;
bool isbackgroundModeEnabled;
id<LinphoneUIControler> uiController;
UIViewController* mCurrentViewController;
}
+(LinphoneManager*) instance;
+(LinphoneCore*) getLc;
-(void) registerLogView:(id<LogView>) view;
-(void) startLibLinphone;
-(void) destroyLibLinphone;
-(void) enterBackgroundMode;
-(void) becomeActive;
-(void) kickOffNetworkConnection;
@property (nonatomic, retain) id<LinphoneUIControler> uiController;
@end

View file

@ -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 <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#import <AVFoundation/AVAudioSession.h>
#import <AudioToolbox/AudioToolbox.h>
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<LogView>) view {
mLogView = view;
}
@end

View file

@ -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 <UIKit/UIKit.h>
@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

View file

@ -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 <UIKit/UIKit.h>
@protocol LogView
-(void) addLog:(NSString*) log;
@end

View file

@ -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 <UIKit/UIKit.h>
@interface UICallButton : UIButton {
@private
char mDigit;
UITextField* mAddress;
UILabel* mDisplayName;
}
-(void) initWithAddress:(UITextField*) address withDisplayName:(UILabel*) displayName;
@end

View file

@ -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

View file

@ -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 <UIKit/UIKit.h>
#include "linphonecore.h"
@interface UIDigitButton : UIButton {
@private
char mDigit;
UITextField* mAddress;
}
-(void) initWithNumber:(char)digit addressField:(UITextField*) address;
@end

View file

@ -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

View file

@ -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 <UIKit/UIKit.h>
@interface UIDuration : UILabel {
@private
NSTimer *durationRefreasher;
}
-(void) start;
-(void) stop;
@end

View file

@ -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

View file

@ -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 <UIKit/UIKit.h>
@interface UIHangUpButton : UIButton {
}
@end

View file

@ -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

View file

@ -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"

View file

@ -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 <UIKit/UIKit.h>
#import "UIToggleButton.h"
@interface UIMuteButton : UIToggleButton<UIToggleButtonDelegate> {
}
@end

View file

@ -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

View file

@ -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 <UIKit/UIKit.h>
#import "UIToggleButton.h"
@interface UISpeakerButton : UIToggleButton<UIToggleButtonDelegate> {
}
@end

View file

@ -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 <AudioToolbox/AudioToolbox.h>
@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

View file

@ -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 <UIKit/UIKit.h>
@protocol UIToggleButtonDelegate
-(void) onOn;
-(void) onOff;
-(bool) isInitialStateOn;
@end
@interface UIToggleButton : UIButton <UIToggleButtonDelegate> {
@private
UIImage* mOnImage;
UIImage* mOffImage;
id<UIToggleButtonDelegate> mActionHandler;
bool mIsOn;
}
-(void) initWithOnImage:(UIImage*) onImage offImage:(UIImage*) offImage;
-(bool) reset;
-(bool) isOn;
-(bool) toggle;
@end

View file

@ -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

View file

@ -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"];
}

View file

@ -19,58 +19,47 @@
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#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 <UITextFieldDelegate,PhoneViewControllerDelegate,UIActionSheetDelegate> {
@interface PhoneViewController : UIViewController <UITextFieldDelegate,UIActionSheetDelegate,LinphoneUIControler> {
@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

View file

@ -18,10 +18,10 @@
*/
#import "PhoneViewController.h"
#import "osip2/osip.h"
#import "linphoneAppDelegate.h"
#import <AVFoundation/AVAudioSession.h>
#import <AudioToolbox/AudioToolbox.h>
#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

View file

@ -2,17 +2,17 @@
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">784</int>
<string key="IBDocument.SystemVersion">10F569</string>
<string key="IBDocument.InterfaceBuilderVersion">788</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<string key="IBDocument.SystemVersion">10J567</string>
<string key="IBDocument.InterfaceBuilderVersion">823</string>
<string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.HIToolboxVersion">462.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">117</string>
<string key="NS.object.0">132</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1"/>
<integer value="114"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -540,15 +540,6 @@
</object>
<int key="connectionID">15</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doAction:</string>
<reference key="source" ref="661303162"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">18</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
@ -661,78 +652,6 @@
</object>
<int key="connectionID">54</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPad:</string>
<reference key="source" ref="201618948"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">1</int>
</object>
<int key="connectionID">84</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPad:</string>
<reference key="source" ref="607229252"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">1</int>
</object>
<int key="connectionID">85</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPad:</string>
<reference key="source" ref="1070392235"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">1</int>
</object>
<int key="connectionID">86</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPad:</string>
<reference key="source" ref="539158319"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">1</int>
</object>
<int key="connectionID">87</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPad:</string>
<reference key="source" ref="539781036"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">1</int>
</object>
<int key="connectionID">88</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPad:</string>
<reference key="source" ref="573280603"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">1</int>
</object>
<int key="connectionID">89</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPad:</string>
<reference key="source" ref="150499342"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">1</int>
</object>
<int key="connectionID">90</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPad:</string>
<reference key="source" ref="616388880"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">1</int>
</object>
<int key="connectionID">91</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPad:</string>
@ -742,42 +661,6 @@
</object>
<int key="connectionID">92</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPad:</string>
<reference key="source" ref="465571136"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">1</int>
</object>
<int key="connectionID">93</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPad:</string>
<reference key="source" ref="602859574"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">1</int>
</object>
<int key="connectionID">94</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPad:</string>
<reference key="source" ref="310945439"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">1</int>
</object>
<int key="connectionID">95</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="602859574"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">98</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">hangup</string>
@ -786,15 +669,6 @@
</object>
<int key="connectionID">109</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doAction:</string>
<reference key="source" ref="319430047"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">110</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">incallView</string>
@ -827,15 +701,6 @@
</object>
<int key="connectionID">123</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doAction:</string>
<reference key="source" ref="963349321"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">124</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">mute</string>
@ -844,222 +709,6 @@
</object>
<int key="connectionID">125</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doAction:</string>
<reference key="source" ref="743511023"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">126</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="1070392235"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">127</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="1070392235"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">8</int>
</object>
<int key="connectionID">128</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="201618948"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">129</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="201618948"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">8</int>
</object>
<int key="connectionID">130</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="539158319"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">131</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="539158319"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">8</int>
</object>
<int key="connectionID">132</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="539781036"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">133</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="539781036"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">8</int>
</object>
<int key="connectionID">134</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="573280603"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">135</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="573280603"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">8</int>
</object>
<int key="connectionID">136</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="150499342"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">137</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="150499342"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">8</int>
</object>
<int key="connectionID">138</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="624378925"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">139</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="624378925"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">8</int>
</object>
<int key="connectionID">140</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="607229252"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">141</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="607229252"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">8</int>
</object>
<int key="connectionID">142</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="465571136"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">143</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="465571136"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">8</int>
</object>
<int key="connectionID">144</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="602859574"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">8</int>
</object>
<int key="connectionID">145</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="310945439"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">146</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="310945439"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">8</int>
</object>
<int key="connectionID">147</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="616388880"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">148</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">doKeyPadUp:</string>
<reference key="source" ref="616388880"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">8</int>
</object>
<int key="connectionID">149</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@ -1246,27 +895,44 @@
<string>1.IBEditorWindowLastContentRect</string>
<string>1.IBPluginDependency</string>
<string>1.IBUserGuides</string>
<string>107.CustomClassName</string>
<string>107.IBPluginDependency</string>
<string>114.IBEditorWindowLastContentRect</string>
<string>114.IBPluginDependency</string>
<string>114.IBUserGuides</string>
<string>115.IBPluginDependency</string>
<string>116.CustomClassName</string>
<string>116.IBPluginDependency</string>
<string>117.CustomClassName</string>
<string>117.IBPluginDependency</string>
<string>118.CustomClassName</string>
<string>118.IBPluginDependency</string>
<string>29.CustomClassName</string>
<string>29.IBPluginDependency</string>
<string>30.CustomClassName</string>
<string>30.IBPluginDependency</string>
<string>31.CustomClassName</string>
<string>31.IBPluginDependency</string>
<string>33.CustomClassName</string>
<string>33.IBPluginDependency</string>
<string>34.CustomClassName</string>
<string>34.IBPluginDependency</string>
<string>35.CustomClassName</string>
<string>35.IBPluginDependency</string>
<string>36.CustomClassName</string>
<string>36.IBPluginDependency</string>
<string>37.CustomClassName</string>
<string>37.IBPluginDependency</string>
<string>38.CustomClassName</string>
<string>38.IBPluginDependency</string>
<string>39.CustomClassName</string>
<string>39.IBPluginDependency</string>
<string>4.IBPluginDependency</string>
<string>40.CustomClassName</string>
<string>40.IBPluginDependency</string>
<string>41.CustomClassName</string>
<string>41.IBPluginDependency</string>
<string>5.CustomClassName</string>
<string>5.IBPluginDependency</string>
<string>7.IBPluginDependency</string>
<string>80.IBEditorWindowLastContentRect</string>
@ -1291,6 +957,7 @@
<int key="affinity">1</int>
</object>
</object>
<string>UIHangUpButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>{{32, 282}, {320, 90}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@ -1303,22 +970,38 @@
</object>
</object>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDuration</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UISpeakerButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIMuteButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDigitButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDigitButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDigitButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDigitButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDigitButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDigitButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDigitButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDigitButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDigitButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDigitButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDigitButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIDigitButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UICallButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>{{53, 318}, {320, 480}}</string>
@ -1573,6 +1256,73 @@
<string key="minorKey"/>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UICallButton</string>
<string key="superclassName">UIButton</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Classes/LinphoneUI/UICallButton.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIDigitButton</string>
<string key="superclassName">UIButton</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Classes/LinphoneUI/UIDigitButton.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIDuration</string>
<string key="superclassName">UILabel</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Classes/LinphoneUI/UIDuration.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIHangUpButton</string>
<string key="superclassName">UIButton</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Classes/LinphoneUI/UIHangUpButton.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIMuteButton</string>
<string key="superclassName">UIToggleButton</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Classes/LinphoneUI/UIMuteButton.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UISpeakerButton</string>
<string key="superclassName">UIToggleButton</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Classes/LinphoneUI/UISpeakerButton.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIToggleButton</string>
<string key="superclassName">UIButton</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">mActionHandler</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">mActionHandler</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">mActionHandler</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Classes/LinphoneUI/UIToggleButton.h</string>
</object>
</object>
</object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -1720,6 +1470,13 @@
<string key="minorKey">UIKit.framework/Headers/UITextField.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIPrintFormatter.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIView</string>
<reference key="sourceIdentifier" ref="725711016"/>
@ -1778,7 +1535,7 @@
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
<integer value="1024" key="NS.object.0"/>
<integer value="1056" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
@ -1810,6 +1567,6 @@
<string>{62, 54}</string>
</object>
</object>
<string key="IBCocoaTouchPluginVersion">117</string>
<string key="IBCocoaTouchPluginVersion">132</string>
</data>
</archive>

View file

@ -20,72 +20,30 @@
#import <UIKit/UIKit.h>
#import <AddressBookUI/ABPeoplePickerNavigationController.h>
#import <SystemConfiguration/SCNetworkReachability.h>
#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 <UIApplicationDelegate,LinphoneTabManagerDelegate,UIAlertViewDelegate> {
@interface linphoneAppDelegate : NSObject <UIApplicationDelegate,UIAlertViewDelegate> {
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

View file

@ -21,89 +21,11 @@
#import "linphoneAppDelegate.h"
#import "ContactPickerDelegate.h"
#import "AddressBook/ABPerson.h"
#import <AVFoundation/AVAudioSession.h>
#import <AudioToolbox/AudioToolbox.h>
#import "ConsoleViewController.h"
#import "MoreViewController.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
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<LinphoneTabManagerDelegate> 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

View file

@ -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 = "<group>"; };
1D3623250D0F684500981E51 /* linphoneAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = linphoneAppDelegate.m; sourceTree = "<group>"; };
1D3623240D0F684500981E51 /* LinphoneAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinphoneAppDelegate.h; sourceTree = "<group>"; };
1D3623250D0F684500981E51 /* LinphoneAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LinphoneAppDelegate.m; sourceTree = "<group>"; };
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 = "<group>"; };
@ -210,11 +219,25 @@
220FAD2F10765B400068D98F /* libspeex.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libspeex.a; path = "liblinphone-sdk/apple-darwin/lib/libspeex.a"; sourceTree = "<group>"; };
220FAD3010765B400068D98F /* libspeexdsp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libspeexdsp.a; path = "liblinphone-sdk/apple-darwin/lib/libspeexdsp.a"; sourceTree = "<group>"; };
220FAE4A10767A6A0068D98F /* PhoneMainView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PhoneMainView.xib; sourceTree = "<group>"; };
2214EB7812F846B1002A5394 /* UICallButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICallButton.h; sourceTree = "<group>"; };
2214EB7912F846B1002A5394 /* UICallButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICallButton.m; sourceTree = "<group>"; };
2214EB8712F84EBB002A5394 /* UIHangUpButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIHangUpButton.h; sourceTree = "<group>"; };
2214EB8812F84EBB002A5394 /* UIHangUpButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIHangUpButton.m; sourceTree = "<group>"; };
2214EB8A12F84FE9002A5394 /* UILinphone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILinphone.h; sourceTree = "<group>"; };
2214EBD812F8558F002A5394 /* UIToggleButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIToggleButton.h; sourceTree = "<group>"; };
2214EBD912F8558F002A5394 /* UIToggleButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIToggleButton.m; sourceTree = "<group>"; };
2214EBF112F86360002A5394 /* UIMuteButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIMuteButton.h; sourceTree = "<group>"; };
2214EBF212F86360002A5394 /* UIMuteButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIMuteButton.m; sourceTree = "<group>"; };
2218A5C412F9597B0088A667 /* LinphoneUIControler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinphoneUIControler.h; sourceTree = "<group>"; };
2218A5CE12F973450088A667 /* LogView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogView.h; sourceTree = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
222A483112F7176F0075F07F /* IncallViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IncallViewController.xib; sourceTree = "<group>"; };
222A483212F7176F0075F07F /* IncallViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IncallViewController.m; sourceTree = "<group>"; };
222A483312F7176F0075F07F /* IncallViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IncallViewController.h; sourceTree = "<group>"; };
223148E31178A08200637D6A /* libilbc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libilbc.a; path = "liblinphone-sdk/apple-darwin/lib/libilbc.a"; sourceTree = "<group>"; };
223148E51178A09900637D6A /* libmsilbc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmsilbc.a; path = "liblinphone-sdk/apple-darwin/lib/mediastreamer/plugins/libmsilbc.a"; sourceTree = "<group>"; };
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 = "<group>"; };
@ -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 = "<group>"; };
2245671C107699F700F10948 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = "<group>"; };
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 = "<group>"; };
2248E90D12F7E4CF00220D9C /* UIDigitButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIDigitButton.m; sourceTree = "<group>"; };
2248E99D12F801C200220D9C /* LinphoneManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinphoneManager.h; sourceTree = "<group>"; };
2248E99E12F801C200220D9C /* LinphoneManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LinphoneManager.m; sourceTree = "<group>"; };
2258633C11410BAC00C5A737 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = "<group>"; };
225CB2E811ABB51000628906 /* clavier-01-106px.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "clavier-01-106px.png"; path = "Resources/clavier-01-106px.png"; sourceTree = "<group>"; };
225CB2E911ABB51000628906 /* clavier-01-108px.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "clavier-01-108px.png"; path = "Resources/clavier-01-108px.png"; sourceTree = "<group>"; };
@ -242,6 +269,10 @@
227BCDC010D4004600FBFD76 /* CallHistoryTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CallHistoryTableViewController.m; sourceTree = "<group>"; };
227BCDC110D4004600FBFD76 /* CallHistoryTableViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CallHistoryTableViewController.xib; sourceTree = "<group>"; };
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 = "<group>"; };
22968A5E12F875C600588287 /* UISpeakerButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UISpeakerButton.m; sourceTree = "<group>"; };
22968A8612F87C2000588287 /* UIDuration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIDuration.h; sourceTree = "<group>"; };
22968A8712F87C2000588287 /* UIDuration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIDuration.m; sourceTree = "<group>"; };
22A10D9E11F88C1F00373793 /* liblinphone.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = liblinphone.xcodeproj; path = submodules/liblinphone.xcodeproj; sourceTree = "<group>"; };
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 = "<group>"; };
@ -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 = "<group>";
};
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 = "<group>";
};
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;
};

View file

@ -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;
};

@ -1 +1 @@
Subproject commit fd5e9b931875505c10be591afa83a11b4b813b40
Subproject commit f89550038a73df8d7ded83252401fea09afd65ba