This repository has been archived by the owner on Aug 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
QIDialerViewController.m
78 lines (60 loc) · 2.87 KB
/
QIDialerViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Copyright (c) 2011-2019, Zingaya, Inc. All rights reserved.
*/
#import "QIAppDelegate.h"
#import "QIDialerViewController.h"
#import "QICallViewController.h"
@interface QIDialerViewController () <QIVoxClientManagerListener>
@end
@implementation QIDialerViewController
- (void)viewDidLoad {
[super viewDidLoad];
[[QIAppDelegate instance].voxManager addListener:self];
}
- (void)callTouched:(UIButton *)sender {
VIVideoFlags *videoFlags = [VIVideoFlags defaultVideoFlags];
VICall *call = [[QIAppDelegate instance].voxManager createCall:self.contactField.text
withVideoFlags:videoFlags
conference:NO];
[self showCallViewController:^(QICallViewController *vc) {
vc.isConferenceCall = NO;
vc.currentCall = call;
[call start];
}];
}
- (void)callConferenceTouched:(UIButton *)sender {
VIVideoFlags *videoFlags = [VIVideoFlags defaultVideoFlags];
VICall *callConference = [[QIAppDelegate instance].voxManager createCall:self.contactField.text
withVideoFlags:videoFlags
conference:YES];
[self showCallViewController:^(QICallViewController *vc) {
vc.isConferenceCall = YES;
vc.currentCall = callConference;
[callConference start];
}];
}
- (void)incomingCallReceived:(VICall *)call withVideoFlags:(VIVideoFlags *)videoFlags {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Incoming call"
message:call.endpoints.firstObject.userDisplayName
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Reject" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
[call rejectWithMode:VIRejectModeDecline headers:nil];
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"Answer" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self showCallViewController:^(QICallViewController *vc){
vc.currentCall = call;
VICallSettings *settings = [VICallSettings new];
settings.videoFlags = videoFlags;
[call answerWithSettings:settings];
}];
}]];
[self.navigationController presentViewController:alert animated:YES completion:nil];
}
- (void)showCallViewController:(void(^)(QICallViewController *vc))completion {
[self performSegueWithIdentifier:@"ShowCall" sender:completion];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
void(^completion)(QICallViewController *vc) = sender;
completion(segue.destinationViewController);
}
@end