Skip to content

Commit

Permalink
Merge pull request #335 from session-foundation/dev
Browse files Browse the repository at this point in the history
Release 1.8.3
  • Loading branch information
mpretty-cyro authored Dec 9, 2024
2 parents bfb668d + 907abf1 commit 3931de8
Show file tree
Hide file tree
Showing 93 changed files with 4,343 additions and 1,865 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "LibSession-Util"]
path = LibSession-Util
url = https://github.com/oxen-io/libsession-util.git
url = https://github.com/session-foundation/libsession-util.git
101 changes: 82 additions & 19 deletions Session.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "53c1182a7d64df9a13a5c0ec4420b2c8da9c4d81d97b2b79b6e8f2946978471b",
"originHash" : "c57241b796915b0642f9c260463b2d6fd7d5198beafde785c590f3a7d80d31f5",
"pins" : [
{
"identity" : "cocoalumberjack",
Expand Down Expand Up @@ -85,21 +85,30 @@
{
"identity" : "session-grdb-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/oxen-io/session-grdb-swift.git",
"location" : "https://github.com/session-foundation/session-grdb-swift.git",
"state" : {
"revision" : "04f480b95263b7c517085100ceb249f879c021d8",
"revision" : "b3643613f1e0f392fa41072ee499da93b4c06b67",
"version" : "106.29.3"
}
},
{
"identity" : "session-ios-yyimage",
"kind" : "remoteSourceControl",
"location" : "https://github.com/oxen-io/session-ios-yyimage.git",
"location" : "https://github.com/session-foundation/session-ios-yyimage",
"state" : {
"revision" : "14786afd2523f80be304b377f9dbab6b7904bf02",
"version" : "1.1.0"
}
},
{
"identity" : "session-lucide",
"kind" : "remoteSourceControl",
"location" : "https://github.com/session-foundation/session-lucide.git",
"state" : {
"revision" : "32fdd138a20e828eea376d01e53efb461cc19ebe",
"version" : "0.468.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
Expand Down
26 changes: 15 additions & 11 deletions Session/Calls/Call Management/SessionCall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import SessionSnodeKit
public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
@objc static let isEnabled = true

private let dependencies: Dependencies

// MARK: - Metadata Properties
public let uuid: String
public let callId: UUID // This is for CallKit
let sessionId: String
public let sessionId: String
let mode: CallMode
var audioMode: AudioMode
public let webRTCSession: WebRTCSession
Expand Down Expand Up @@ -147,7 +149,8 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {

// MARK: - Initialization

init(_ db: Database, for sessionId: String, uuid: String, mode: CallMode, outgoing: Bool = false) {
init(_ db: Database, for sessionId: String, uuid: String, mode: CallMode, outgoing: Bool = false, using dependencies: Dependencies) {
self.dependencies = dependencies
self.sessionId = sessionId
self.uuid = uuid
self.callId = UUID()
Expand All @@ -172,8 +175,8 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
WebRTCSession.current = self.webRTCSession
self.webRTCSession.delegate = self

if AppEnvironment.shared.callManager.currentCall == nil {
AppEnvironment.shared.callManager.currentCall = self
if Singleton.callManager.currentCall == nil {
Singleton.callManager.setCurrentCall(self)
}
else {
SNLog("[Calls] A call is ongoing.")
Expand All @@ -183,12 +186,12 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
// stringlint:ignore_contents
func reportIncomingCallIfNeeded(completion: @escaping (Error?) -> Void) {
guard case .answer = mode else {
SessionCallManager.reportFakeCall(info: "Call not in answer mode")
SessionCallManager.reportFakeCall(info: "Call not in answer mode", using: dependencies)
return
}

setupTimeoutTimer()
AppEnvironment.shared.callManager.reportIncomingCall(self, callerName: contactName) { error in
Singleton.callManager.reportIncomingCall(self, callerName: contactName) { error in
completion(error)
}
}
Expand Down Expand Up @@ -290,7 +293,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {

// MARK: - Call Message Handling

public func updateCallMessage(mode: EndCallMode) {
public func updateCallMessage(mode: EndCallMode, using dependencies: Dependencies) {
guard let callInteractionId: Int64 = callInteractionId else { return }

let duration: TimeInterval = self.duration
Expand Down Expand Up @@ -351,11 +354,12 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
threadId: interaction.threadId,
threadVariant: threadVariant,
includingOlder: false,
trySendReadReceipt: false
trySendReadReceipt: false,
using: dependencies
)
},
completion: { _, _ in
SessionCallManager.suspendDatabaseIfCallEndedInBackground()
Singleton.callManager.suspendDatabaseIfCallEndedInBackground()
}
)
}
Expand Down Expand Up @@ -404,7 +408,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
guard Singleton.hasAppContext else { return }
if let callVC = Singleton.appContext.frontmostViewController as? CallVC { callVC.handleEndCallMessage() }
if let miniCallView = MiniCallView.current { miniCallView.dismiss() }
AppEnvironment.shared.callManager.reportCurrentCallEnded(reason: .remoteEnded)
Singleton.callManager.reportCurrentCallEnded(reason: .remoteEnded)
}
}

Expand Down Expand Up @@ -461,7 +465,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
timeOutTimer = Timer.scheduledTimerOnMainThread(withTimeInterval: timeInterval, repeats: false) { _ in
self.didTimeout = true

AppEnvironment.shared.callManager.endCall(self) { error in
Singleton.callManager.endCall(self) { error in
self.timeOutTimer = nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

import Foundation
import CallKit
import SessionMessagingKit
import SessionUtilitiesKit

extension SessionCallManager {
public func startCall(_ call: SessionCall, completion: ((Error?) -> Void)?) {
guard case .offer = call.mode else { return }
guard !call.hasConnected else { return }
public func startCall(_ call: CurrentCallProtocol?, completion: ((Error?) -> Void)?) {
guard
let call: SessionCall = call as? SessionCall,
case .offer = call.mode,
!call.hasConnected
else { return }

reportOutgoingCall(call)

Expand All @@ -28,9 +32,9 @@ extension SessionCallManager {
}
}

public func answerCall(_ call: SessionCall, completion: ((Error?) -> Void)?) {
if callController != nil {
let answerCallAction = CXAnswerCallAction(call: call.callId)
public func answerCall(_ call: CurrentCallProtocol?, completion: ((Error?) -> Void)?) {
if callController != nil, let callId: UUID = call?.callId {
let answerCallAction = CXAnswerCallAction(call: callId)
let transaction = CXTransaction()
transaction.addAction(answerCallAction)

Expand All @@ -42,9 +46,9 @@ extension SessionCallManager {
}
}

public func endCall(_ call: SessionCall, completion: ((Error?) -> Void)?) {
if callController != nil {
let endCallAction = CXEndCallAction(call: call.callId)
public func endCall(_ call: CurrentCallProtocol?, completion: ((Error?) -> Void)?) {
if callController != nil, let callId: UUID = call?.callId {
let endCallAction = CXEndCallAction(call: callId)
let transaction = CXTransaction()
transaction.addAction(endCallAction)

Expand Down
Loading

0 comments on commit 3931de8

Please sign in to comment.