Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/3.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmer Loen committed Nov 8, 2018
2 parents 45d85d6 + 60f147c commit db00682
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 42 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ All notable changes to this project will be documented in this file.

---

## [3.4.1](https://github.com/VoIPGRID/VialerSIPLib/tree/3.4.1) (11/08/2018)

Released on Thursday, November 8, 2018.

### Fixed

- When account registration returns a Forbidden or Unauthorized remove the account from the endpoint (#163)
- Updated the prioritization that the caller info coming from the PBX has higher priority then the phonebook (#164)

## [3.4.0](https://github.com/VoIPGRID/VialerSIPLib/tree/3.4.0) (09/11/2018)

Released on Thursday, October 1, 2018.
Released on Thursday, October 11, 2018.

Removed some old deprecated functions for configuring the codecs.
See the Example project on how to configure the codecs for the endpoint.
Expand Down
9 changes: 7 additions & 2 deletions Pod/Classes/CallKitProviderDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ - (CXProviderConfiguration *)providerConfiguration NS_AVAILABLE_IOS(10.0){
- (void)reportIncomingCall:(VSLCall *)call {
if (@available(iOS 10.0, *)) {
CXCallUpdate *update = [[CXCallUpdate alloc] init];
CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:call.callerNumber];
update.remoteHandle = handle;
update.localizedCallerName = call.callerName;

NSString * handleValue = @"";
if ([update.localizedCallerName length] == 0) { // Doing this to not let the caller contact name override the platform's one
handleValue = call.callerNumber;
}
CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:handleValue];
update.remoteHandle = handle;

VSLLogVerbose(@"UUID as sent to CallKit provider: %@", call.uuid.UUIDString);
[self.provider reportNewIncomingCallWithUUID:call.uuid update:update completion:^(NSError * _Nullable error) {
if (error) {
Expand Down
6 changes: 5 additions & 1 deletion Pod/Classes/VSLAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ typedef NS_ENUM(NSInteger, VSLAccountErrors) {
* Unable to register the account
*/
VSLAccountErrorRegistrationFailed,
/**
* When the account has invalid info and registrations fails with a 403.
*/
VSLAccountErrorRegistrationFailedInvalidAccount
};
#define VSLAccountErrorsString(VSLAccountErrors) [@[@"VSLAccountErrorCannotConfigureAccount", @"VSLAccountErrorFailedCallingNumber", @"VSLAccountErrorRegistrationFailed"] objectAtIndex:VSLAccountErrors]
#define VSLAccountErrorsString(VSLAccountErrors) [@[@"VSLAccountErrorCannotConfigureAccount", @"VSLAccountErrorFailedCallingNumber", @"VSLAccountErrorRegistrationFailed", @"VSLAccountErrorRegistrationFailedInvalidAccount"] objectAtIndex:VSLAccountErrors]

/**
* Possible states for an account.
Expand Down
19 changes: 18 additions & 1 deletion Pod/Classes/VSLAccount.m
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ - (void)accountStateChanged {

pjsip_status_code code = accountInfo.status;

if (code == 0 || accountInfo.expires == -1) {
if (code == 0 || (code != PJSIP_SC_FORBIDDEN && code != PJSIP_SC_UNAUTHORIZED && accountInfo.expires == -1)) {
self.accountState = VSLAccountStateDisconnected;
if (self.shouldReregister) {
[self registerAccountWithCompletion:^(BOOL success, NSError * _Nullable error) {
Expand Down Expand Up @@ -334,6 +334,23 @@ - (void)accountStateChanged {
}
} else {
self.accountState = VSLAccountStateDisconnected;
// SIP account info is incorrect!
if (code == PJSIP_SC_FORBIDDEN || code == PJSIP_SC_UNAUTHORIZED) {
VSLLogWarning(@"Account is invalid! SIP info not correct.");
// Remove the invalid account.
[self removeAccount];
// Post a notification so the user could be informed.
if (self.registrationCompletionBlock) {
NSError *error = [NSError VSLUnderlyingError:nil
localizedDescriptionKey:NSLocalizedString(@"Account unregistration failed", nil)
localizedFailureReasonError:[NSString stringWithFormat:NSLocalizedString(@"PJSIP status code: %d", nil), code]
errorDomain:VSLAccountErrorDomain
errorCode:VSLAccountErrorRegistrationFailed];
self.registrationCompletionBlock(NO, error);
self.registrationCompletionBlock = nil;
self.registrationInProgress = NO;
}
}
}
}

Expand Down
69 changes: 36 additions & 33 deletions Pod/Classes/VSLCallManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,41 +63,44 @@ - (CXCallController *)callController NS_AVAILABLE_IOS(10.0) {
}

- (void)startCallToNumber:(NSString *)number forAccount:(VSLAccount *)account completion:(void (^)(VSLCall *call, NSError *error))completion {
if (account.accountState != VSLAccountStateConnected) {
[account registerAccountWithCompletion:nil];
}

VSLCall *call = [[VSLCall alloc] initOutboundCallWithNumberToCall:number account:account];
[self addCall:call];

if (@available(iOS 10.0, *)) {
CXHandle *numberHandle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:call.numberToCall];
CXAction *startCallAction = [[CXStartCallAction alloc] initWithCallUUID:call.uuid handle:numberHandle];

[self requestCallKitAction:startCallAction completion:^(NSError *error) {
if (error) {
VSLLogError(@"Error requesting \"Start Call Transaction\" error: %@", error);
[self removeCall:call];
VSLBlockSafeRun(completion,nil, error);
} else {
VSLLogInfo(@"\"Start Call Transaction\" requested succesfully for Call(%@) with account(%ld)", call.uuid.UUIDString, (long)account.accountId);
VSLBlockSafeRun(completion,call, nil);
}
}];
} else {
VSLLogVerbose(@"Starting call: %@", call.uuid.UUIDString);
[self.audioController configureAudioSession];
[call startWithCompletion:^(NSError *error) {
if (error) {
VSLLogError(@"Error starting call(%@): %@", call.uuid.UUIDString, error);
VSLBlockSafeRun(completion,nil, error);
[account registerAccountWithCompletion:^(BOOL success, NSError * _Nullable error) {
if (!success) {
VSLLogError(@"Error registering the account: %@", error);
VSLBlockSafeRun(completion, nil, error);
} else {
VSLCall *call = [[VSLCall alloc] initOutboundCallWithNumberToCall:number account:account];
[self addCall:call];

if (@available(iOS 10.0, *)) {
CXHandle *numberHandle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:call.numberToCall];
CXAction *startCallAction = [[CXStartCallAction alloc] initWithCallUUID:call.uuid handle:numberHandle];

[self requestCallKitAction:startCallAction completion:^(NSError *error) {
if (error) {
VSLLogError(@"Error requesting \"Start Call Transaction\" error: %@", error);
[self removeCall:call];
VSLBlockSafeRun(completion, nil, error);
} else {
VSLLogInfo(@"\"Start Call Transaction\" requested succesfully for Call(%@) with account(%ld)", call.uuid.UUIDString, (long)account.accountId);
VSLBlockSafeRun(completion, call, nil);
}
}];
} else {
VSLLogInfo(@"Call(%@) started", call.uuid.UUIDString);
[self.audioController activateAudioSession];
VSLBlockSafeRun(completion,call, nil);
VSLLogVerbose(@"Starting call: %@", call.uuid.UUIDString);
[self.audioController configureAudioSession];
[call startWithCompletion:^(NSError *error) {
if (error) {
VSLLogError(@"Error starting call(%@): %@", call.uuid.UUIDString, error);
VSLBlockSafeRun(completion, nil, error);
} else {
VSLLogInfo(@"Call(%@) started", call.uuid.UUIDString);
[self.audioController activateAudioSession];
VSLBlockSafeRun(completion, call, nil);
}
}];
}
}];
}
}
}];
}

- (void)answerCall:(VSLCall *)call completion:(void (^)(NSError *error))completion {
Expand Down
2 changes: 1 addition & 1 deletion Pod/Classes/VSLEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ typedef NS_ENUM(NSInteger, VSLEndpointState) {
/**
* This will update the codec configuration.
*
* @param codecConfigration VSLCodecConfiguration Instance of an VSLCodecConfiguration
* @param codecConfiguration VSLCodecConfiguration Instance of an VSLCodecConfiguration
*/
- (BOOL)updateCodecConfiguration:(VSLCodecConfiguration * _Nonnull)codecConfiguration;
@end
2 changes: 1 addition & 1 deletion Pod/Classes/VialerSIPLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ typedef NS_ENUM(NSUInteger, VialerSIPLibErrors) {
/**
* This will update the codec configuration on the SIP endpoint
*
* @param codecConfigration VSLCodecConfiguration Instance of an VSLCodecConfiguration
* @param codecConfiguration VSLCodecConfiguration Instance of an VSLCodecConfiguration
*/
- (BOOL)updateCodecConfiguration:(VSLCodecConfiguration * _Nonnull)codecConfiguration;

Expand Down
2 changes: 1 addition & 1 deletion Pod/Classes/VialerSIPLib.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ - (BOOL)configureLibraryWithEndPointConfiguration:(VSLEndpointConfiguration * _N
}

- (void)removeEndpoint {
if (self.endpointAvailable) {
if (self.endpointAvailable && self.accounts.count == 0) {
[self.endpoint destroyPJSUAInstance];
}
}
Expand Down
2 changes: 1 addition & 1 deletion VialerSIPLib.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Pod::Spec.new do |s|
s.name = "VialerSIPLib"
s.version = "3.4.0"
s.version = "3.4.1"
s.summary = "Vialer SIP Library for iOS"
s.description = "Objective-C wrapper around PJSIP."
s.homepage = "https://github.com/VoIPGRID/VialerSIPLib"
Expand Down

0 comments on commit db00682

Please sign in to comment.