Conference begins to work

This commit is contained in:
Pierre-Eric Pelloux-Prayer 2011-11-03 16:49:44 +01:00
parent 8c8843d035
commit c5de6fff07
5 changed files with 663 additions and 469 deletions

View file

@ -39,6 +39,7 @@
UISpeakerButton* speaker;
UIButton* contacts;
UITableView* callTableView;
UIButton* addCall, *mergeCalls;
//key pad
@ -64,6 +65,8 @@
NSTimer *durationRefreasher;
ABPeoplePickerNavigationController* myPeoplePickerController;
UITableViewCell* selectedCell;
}
-(void)displayStatus:(NSString*) message;
@ -84,6 +87,8 @@
@property (nonatomic, retain) IBOutlet UIButton* speaker;
@property (nonatomic, retain) IBOutlet UIButton* contacts;
@property (nonatomic, retain) IBOutlet UITableView* callTableView;
@property (nonatomic, retain) IBOutlet UIButton* addCall;
@property (nonatomic, retain) IBOutlet UIButton* mergeCalls;
@property (nonatomic, retain) IBOutlet UIButton* one;

View file

@ -40,6 +40,8 @@
@synthesize speaker;
@synthesize contacts;
@synthesize callTableView;
@synthesize addCall;
@synthesize mergeCalls;
@synthesize one;
@synthesize two;
@ -67,6 +69,23 @@
*/
bool isInConference(LinphoneCall* call) {
return linphone_call_get_current_params(call)->in_conference;
}
int callCount(LinphoneCore* lc) {
int count = 0;
const MSList* calls = linphone_core_get_calls(lc);
while (calls != 0) {
if (!isInConference((LinphoneCall*)calls->data)) {
count++;
}
calls = calls->next;
}
return count;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
@ -91,8 +110,28 @@
[nine initWithNumber:'9'];
[star initWithNumber:'*'];
[hash initWithNumber:'#'];
[addCall addTarget:self action:@selector(addCallPressed) forControlEvents:UIControlEventTouchDown];
[mergeCalls addTarget:self action:@selector(mergeCallsPressed) forControlEvents:UIControlEventTouchDown];
[mergeCalls setHidden:YES];
}
-(void) addCallPressed {
[self dismissModalViewControllerAnimated:true];
}
-(void) mergeCallsPressed {
LinphoneCore* lc = [LinphoneManager getLc];
const MSList* calls = linphone_core_get_calls(lc);
while (calls != 0) {
LinphoneCall* call = (LinphoneCall*)calls->data;
if (!isInConference(call)) {
linphone_core_add_to_conference(lc, call);
}
calls = calls->next;
}
}
-(void)updateCallsDurations {
@ -109,6 +148,7 @@
selector:@selector(updateCallsDurations)
userInfo:nil
repeats:YES];
selectedCell = nil;
}
}
@ -116,6 +156,7 @@
if (durationRefreasher != nil) {
[durationRefreasher invalidate];
durationRefreasher=nil;
selectedCell = nil;
}
}
@ -156,9 +197,8 @@
}
-(void) displayInCall:(LinphoneCall*) call FromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName {
[callDuration start];
dismissed = false;
[callTableView reloadData];
[callTableView reloadData];
}
-(void) displayDialerFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName {
[callDuration stop];
@ -170,6 +210,14 @@
[mute reset];
[pause reset];
if (callCount([LinphoneManager getLc]) > 1) {
[pause setHidden:YES];
[mergeCalls setHidden:NO];
} else {
[pause setHidden:NO];
[mergeCalls setHidden:YES];
}
[callTableView reloadData];
}
@ -216,23 +264,6 @@
[super dealloc];
}
bool isInConference(LinphoneCall* call) {
return linphone_call_get_current_params(call)->in_conference;
}
int callCount(LinphoneCore* lc) {
int count = 0;
const MSList* calls = linphone_core_get_calls(lc);
while (calls != 0) {
if (!isInConference((LinphoneCall*)calls->data)) {
count++;
}
calls = calls->next;
}
return count;
}
-(LinphoneCall*) retrieveCallAtIndex: (NSInteger) index inConference:(bool) conf{
const MSList* calls = linphone_core_get_calls([LinphoneManager getLc]);
@ -284,12 +315,19 @@ int callCount(LinphoneCore* lc) {
}
[cell.detailTextLabel setText:ms];
if (linphone_core_get_current_call([LinphoneManager getLc]) == call)
cell.accessoryType = UITableViewCellAccessoryCheckmark;
cell.backgroundColor = [UIColor colorWithRed:0 green:1 blue:0 alpha:0.5];
else if (confActive && isInConference(call))
cell.backgroundColor = [UIColor colorWithRed:0 green:1 blue:0 alpha:0.5];
else
cell.backgroundColor = [UIColor colorWithRed:1 green:0.5 blue:0 alpha:0.5];
/*if (cell == selectedCell)
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryNone;
cell.accessoryType = UITableViewCellAccessoryNone;*/
}
@ -301,8 +339,6 @@ int callCount(LinphoneCore* lc) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
ms_message("pouet");
LinphoneCore* lc = [LinphoneManager getLc];
if (indexPath.section == 0 && linphone_core_get_conference_size(lc) > 0)
[self updateCell:cell withCall: [self retrieveCallAtIndex:indexPath.row inConference:true] conferenceActive:linphone_core_is_in_conference(lc)];
@ -363,5 +399,20 @@ int callCount(LinphoneCore* lc) {
return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//selectedCell = [tableView cellForRowAtIndexPath:indexPath];
bool inConf = (indexPath.section == 0 && linphone_core_get_conference_size([LinphoneManager getLc]) > 0);
if (inConf) {
linphone_core_enter_conference([LinphoneManager getLc]);
} else {
LinphoneCall* call = [self retrieveCallAtIndex:indexPath.row inConference:NO];
linphone_core_resume_call([LinphoneManager getLc], call);
}
[self updateUIFromLinphoneState: nil];
}
@end

File diff suppressed because it is too large Load diff

View file

@ -32,7 +32,7 @@
[error show];
return;
}
if (!linphone_core_in_call([LinphoneManager getLc])) {
if (TRUE /*!linphone_core_in_call([LinphoneManager getLc])*/) {
LinphoneProxyConfig* proxyCfg;
//get default proxy
linphone_core_get_default_proxy([LinphoneManager getLc],&proxyCfg);

View file

@ -200,7 +200,7 @@
-(void) displayCall:(LinphoneCall*) call InProgressFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName {
[self displayInCall: call ViewforUser:username
withDisplayName:displayName];
[__call setEnabled:false];
//[__call setEnabled:false];
[callDuration setText:NSLocalizedString(@"Calling...",nil)];
if ([speaker isOn]) [speaker toggle] ; //preset to off
}