Skip to content

Commit 82deef8

Browse files
authored
Merge pull request #494 from session-foundation/dev
Release 2.14.0
2 parents aa4f3b5 + f68708c commit 82deef8

File tree

523 files changed

+38872
-20759
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

523 files changed

+38872
-20759
lines changed

Scripts/build_libSession_util.sh

Lines changed: 117 additions & 161 deletions
Large diffs are not rendered by default.

Session.xcodeproj/project.pbxproj

Lines changed: 406 additions & 333 deletions
Large diffs are not rendered by default.

Session/Calls/Call Management/SessionCall.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
206206

207207
// MARK: - Actions
208208

209-
public func startSessionCall(_ db: Database) {
209+
public func startSessionCall(_ db: ObservingDatabase) {
210210
let sessionId: String = self.sessionId
211211
let messageInfo: CallMessage.MessageInfo = CallMessage.MessageInfo(state: .outgoing)
212212

@@ -245,10 +245,10 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
245245

246246
try? webRTCSession
247247
.sendPreOffer(
248-
db,
249248
message: message,
249+
threadId: thread.id,
250250
interactionId: interaction?.id,
251-
in: thread
251+
authMethod: try Authentication.with(db, swarmPublicKey: thread.id, using: dependencies)
252252
)
253253
.retry(5)
254254
// Start the timeout timer for the call

Session/Calls/Call Management/SessionCallManager+Action.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension SessionCallManager {
1717
return true
1818
}
1919

20-
public func answerCallAction() {
20+
@MainActor public func answerCallAction() {
2121
guard let call: SessionCall = (self.currentCall as? SessionCall) else { return }
2222

2323
if dependencies[singleton: .appContext].frontMostViewController is CallVC {

Session/Calls/Call Management/SessionCallManager+CXCallController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extension SessionCallManager {
4141
requestTransaction(transaction, completion: completion)
4242
}
4343
else {
44-
answerCallAction()
44+
Task { @MainActor [weak self] in self?.answerCallAction() }
4545
completion?(nil)
4646
}
4747
}

Session/Calls/Call Management/SessionCallManager+CXProvider.swift

Lines changed: 59 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,65 @@ import SessionUtilitiesKit
77

88
extension SessionCallManager: CXProviderDelegate {
99
public func providerDidReset(_ provider: CXProvider) {
10-
Log.assertOnMainThread()
11-
(currentCall as? SessionCall)?.endSessionCall()
10+
Task { @MainActor [weak self] in
11+
(self?.currentCall as? SessionCall)?.endSessionCall()
12+
}
1213
}
1314

1415
public func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
15-
Log.assertOnMainThread()
16-
if startCallAction() {
17-
action.fulfill()
18-
}
19-
else {
20-
action.fail()
16+
Task { @MainActor [weak self] in
17+
if self?.startCallAction() == true {
18+
action.fulfill()
19+
}
20+
else {
21+
action.fail()
22+
}
2123
}
2224
}
2325

2426
public func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
25-
Log.assertOnMainThread()
26-
Log.debug(.calls, "Perform CXAnswerCallAction")
27-
28-
guard let call: SessionCall = (self.currentCall as? SessionCall) else {
29-
Log.warn("[CallKit] No session call")
30-
return action.fail()
31-
}
32-
33-
call.answerCallAction = action
34-
35-
if dependencies[singleton: .appContext].isMainAppAndActive {
36-
self.answerCallAction()
37-
}
38-
else {
39-
call.answerSessionCallInBackground()
27+
Task { @MainActor [weak self, appContext = dependencies[singleton: .appContext]] in
28+
Log.debug(.calls, "Perform CXAnswerCallAction")
29+
30+
guard let call: SessionCall = (self?.currentCall as? SessionCall) else {
31+
Log.warn("[CallKit] No session call")
32+
return action.fail()
33+
}
34+
35+
call.answerCallAction = action
36+
37+
if appContext.isMainAppAndActive {
38+
self?.answerCallAction()
39+
}
40+
else {
41+
call.answerSessionCallInBackground()
42+
}
4043
}
4144
}
4245

4346
public func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
44-
Log.debug(.calls, "Perform CXEndCallAction")
45-
Log.assertOnMainThread()
46-
47-
if endCallAction() {
48-
action.fulfill()
49-
}
50-
else {
51-
action.fail()
47+
Task { @MainActor [weak self] in
48+
Log.debug(.calls, "Perform CXEndCallAction")
49+
50+
if self?.endCallAction() == true {
51+
action.fulfill()
52+
}
53+
else {
54+
action.fail()
55+
}
5256
}
5357
}
5458

5559
public func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
56-
Log.debug(.calls, "Perform CXSetMutedCallAction, isMuted: \(action.isMuted)")
57-
Log.assertOnMainThread()
58-
59-
if setMutedCallAction(isMuted: action.isMuted) {
60-
action.fulfill()
61-
}
62-
else {
63-
action.fail()
60+
Task { @MainActor [weak self] in
61+
Log.debug(.calls, "Perform CXSetMutedCallAction, isMuted: \(action.isMuted)")
62+
63+
if self?.setMutedCallAction(isMuted: action.isMuted) == true {
64+
action.fulfill()
65+
}
66+
else {
67+
action.fail()
68+
}
6469
}
6570
}
6671

@@ -73,20 +78,24 @@ extension SessionCallManager: CXProviderDelegate {
7378
}
7479

7580
public func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
76-
Log.debug(.calls, "Audio session did activate.")
77-
Log.assertOnMainThread()
78-
guard let call: SessionCall = (self.currentCall as? SessionCall) else { return }
79-
80-
call.webRTCSession.audioSessionDidActivate(audioSession)
81-
if call.mode == .offer && !call.hasConnected { CallRingTonePlayer.shared.startPlayingRingTone() }
81+
Task { @MainActor [weak self] in
82+
Log.debug(.calls, "Audio session did activate.")
83+
84+
guard let call: SessionCall = (self?.currentCall as? SessionCall) else { return }
85+
86+
call.webRTCSession.audioSessionDidActivate(audioSession)
87+
if call.mode == .offer && !call.hasConnected { CallRingTonePlayer.shared.startPlayingRingTone() }
88+
}
8289
}
8390

8491
public func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
85-
Log.debug(.calls, "Audio session did deactivate.")
86-
Log.assertOnMainThread()
87-
guard let call: SessionCall = (self.currentCall as? SessionCall) else { return }
88-
89-
call.webRTCSession.audioSessionDidDeactivate(audioSession)
92+
Task { @MainActor [weak self] in
93+
Log.debug(.calls, "Audio session did deactivate.")
94+
95+
guard let call: SessionCall = (self?.currentCall as? SessionCall) else { return }
96+
97+
call.webRTCSession.audioSessionDidDeactivate(audioSession)
98+
}
9099
}
91100
}
92101

Session/Calls/Call Management/SessionCallManager.swift

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
209209
contactName: Profile.displayName(
210210
db,
211211
id: caller,
212-
threadVariant: .contact,
213-
using: dependencies
212+
threadVariant: .contact
214213
),
215214
uuid: uuid,
216215
mode: mode,
@@ -267,26 +266,14 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
267266
currentWebRTCSession.handleICECandidates(candidates)
268267
}
269268

270-
public func handleAnswerMessage(_ message: CallMessage) {
269+
@MainActor public func handleAnswerMessage(_ message: CallMessage) {
271270
guard dependencies[singleton: .appContext].isValid else { return }
272-
guard Thread.isMainThread else {
273-
DispatchQueue.main.async {
274-
self.handleAnswerMessage(message)
275-
}
276-
return
277-
}
278271

279272
(dependencies[singleton: .appContext].frontMostViewController as? CallVC)?.handleAnswerMessage(message)
280273
}
281274

282-
public func dismissAllCallUI() {
275+
@MainActor public func dismissAllCallUI() {
283276
guard dependencies[singleton: .appContext].isValid else { return }
284-
guard Thread.isMainThread else {
285-
DispatchQueue.main.async {
286-
self.dismissAllCallUI()
287-
}
288-
return
289-
}
290277

291278
IncomingCallBanner.current?.dismiss()
292279
(dependencies[singleton: .appContext].frontMostViewController as? CallVC)?.handleEndCallMessage()

Session/Calls/CallVC.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,10 @@ final class CallVC: UIViewController, VideoPreviewDelegate, AVRoutePickerViewDel
570570
try Profile.fetchOne(db, id: call.sessionId)
571571
}
572572

573-
switch profile?.profilePictureFileName {
574-
case .some(let fileName): profilePictureView.loadImage(from: fileName)
573+
switch profile?.displayPictureUrl.map({ try? dependencies[singleton: .displayPictureManager].path(for: $0) }) {
574+
case .some(let filePath): profilePictureView.loadImage(from: filePath)
575575
case .none:
576-
profilePictureView.image = PlaceholderIcon.generate(
576+
profilePictureView.loadPlaceholder(
577577
seed: call.sessionId,
578578
text: call.contactName,
579579
size: 300
@@ -641,7 +641,7 @@ final class CallVC: UIViewController, VideoPreviewDelegate, AVRoutePickerViewDel
641641
}
642642

643643
// MARK: Call signalling
644-
func handleAnswerMessage(_ message: CallMessage) {
644+
@MainActor func handleAnswerMessage(_ message: CallMessage) {
645645
callInfoLabel.text = "callsConnecting".localized()
646646
}
647647

Session/Calls/Views & Modals/IncomingCallBanner.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ final class IncomingCallBanner: UIView, UIGestureRecognizerDelegate {
131131
profilePictureView.update(
132132
publicKey: call.sessionId,
133133
threadVariant: .contact,
134-
displayPictureFilename: nil,
134+
displayPictureUrl: nil,
135135
profile: dependencies[singleton: .storage].read { [sessionId = call.sessionId] db in
136136
Profile.fetchOrCreate(db, id: sessionId)
137137
},

Session/Calls/WebRTC/WebRTCSession+MessageHandling.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension WebRTCSession {
1515
}
1616

1717
public func handleRemoteSDP(_ sdp: RTCSessionDescription, from sessionId: String) {
18-
Log.info(.calls, "Received remote SDP: \(sdp.sdp).")
18+
Log.debug(.calls, "Received remote SDP: \(sdp.sdp).")
1919

2020
peerConnection?.setRemoteDescription(sdp, completionHandler: { [weak self] error in
2121
if let error = error {

0 commit comments

Comments
 (0)