forked from mirrors/linphone-iphone
Send and clear logs
This commit is contained in:
parent
a209349f95
commit
b576785399
7 changed files with 83 additions and 22 deletions
|
|
@ -67,6 +67,9 @@ final class ContactsManager {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
self.linphoneFriendList = try core.getFriendListByName(name: self.linphoneAddressBookFriendList) ?? core.createFriendList()
|
self.linphoneFriendList = try core.getFriendListByName(name: self.linphoneAddressBookFriendList) ?? core.createFriendList()
|
||||||
|
|
||||||
|
//self.linphoneFriendList?.updateSubscriptions()
|
||||||
|
print("friendListfriendListfriendListfriendList \(self.linphoneFriendList!.rlsAddress)")
|
||||||
} catch let error {
|
} catch let error {
|
||||||
print("\(#function) - Failed to enumerate contacts: \(error)")
|
print("\(#function) - Failed to enumerate contacts: \(error)")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,10 @@ final class CoreContext: ObservableObject {
|
||||||
|
|
||||||
coreQueue.async {
|
coreQueue.async {
|
||||||
let configDir = Factory.Instance.getConfigDir(context: nil)
|
let configDir = Factory.Instance.getConfigDir(context: nil)
|
||||||
|
|
||||||
|
Factory.Instance.logCollectionPath = configDir
|
||||||
|
Factory.Instance.enableLogCollection(state: LogCollectionState.Enabled)
|
||||||
|
|
||||||
let url = NSURL(fileURLWithPath: configDir)
|
let url = NSURL(fileURLWithPath: configDir)
|
||||||
if let pathComponent = url.appendingPathComponent("linphonerc") {
|
if let pathComponent = url.appendingPathComponent("linphonerc") {
|
||||||
let filePath = pathComponent.path
|
let filePath = pathComponent.path
|
||||||
|
|
@ -72,24 +76,31 @@ final class CoreContext: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let config: Config! = Config.newForSharedCore(
|
let config = try? Factory.Instance.createConfigWithFactory(
|
||||||
appGroupId: "group.org.linphone.phone.msgNotification",
|
path: "\(configDir)/linphonerc",
|
||||||
configFilename: "linphonerc",
|
factoryPath: Bundle.main.path(forResource: "linphonerc-factory", ofType: nil)
|
||||||
factoryConfigFilename: Bundle.main.path(forResource: "linphonerc-factory", ofType: nil)
|
|
||||||
)
|
)
|
||||||
|
if config != nil {
|
||||||
self.mCore = try? Factory.Instance.createCoreWithConfig(config: config, systemContext: nil)
|
self.mCore = try? Factory.Instance.createCoreWithConfig(config: config!, systemContext: nil)
|
||||||
|
}
|
||||||
|
|
||||||
self.mCore.autoIterateEnabled = false
|
self.mCore.autoIterateEnabled = false
|
||||||
self.mCore.friendsDatabasePath = "\(configDir)/friends.db"
|
self.mCore.friendsDatabasePath = "\(configDir)/friends.db"
|
||||||
|
|
||||||
|
//self.mCore.logCollectionUploadServerUrl = "https://www.linphone.org:444/lft.php"
|
||||||
|
//self.mCore.friendListSubscriptionEnabled = true
|
||||||
|
|
||||||
|
print("configDirconfigDir \(configDir)")
|
||||||
|
|
||||||
self.mCore.publisher?.onGlobalStateChanged?.postOnMainQueue { (cbVal: (core: Core, state: GlobalState, message: String)) in
|
self.mCore.publisher?.onGlobalStateChanged?.postOnMainQueue { (cbVal: (core: Core, state: GlobalState, message: String)) in
|
||||||
if cbVal.state == GlobalState.On {
|
if cbVal.state == GlobalState.On {
|
||||||
self.defaultAccount = self.mCore.defaultAccount
|
self.defaultAccount = self.mCore.defaultAccount
|
||||||
} else if cbVal.state == GlobalState.Off {
|
} else if cbVal.state == GlobalState.Off {
|
||||||
self.defaultAccount = nil
|
self.defaultAccount = nil
|
||||||
}
|
}
|
||||||
|
self.coreIsStarted = true
|
||||||
}
|
}
|
||||||
|
|
||||||
try? self.mCore.start()
|
try? self.mCore.start()
|
||||||
|
|
||||||
// Create a Core listener to listen for the callback we need
|
// Create a Core listener to listen for the callback we need
|
||||||
|
|
@ -115,7 +126,6 @@ final class CoreContext: ObservableObject {
|
||||||
if cbVal.state == .Ok {
|
if cbVal.state == .Ok {
|
||||||
self.loggingInProgress = false
|
self.loggingInProgress = false
|
||||||
self.loggedIn = true
|
self.loggedIn = true
|
||||||
self.coreIsStarted = true
|
|
||||||
} else if cbVal.state == .Progress {
|
} else if cbVal.state == .Progress {
|
||||||
self.loggingInProgress = true
|
self.loggingInProgress = true
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,9 @@ struct LinphoneApp: App {
|
||||||
@State private var historyViewModel: HistoryViewModel?
|
@State private var historyViewModel: HistoryViewModel?
|
||||||
@State private var historyListViewModel: HistoryListViewModel?
|
@State private var historyListViewModel: HistoryListViewModel?
|
||||||
|
|
||||||
@State private var isActive = true
|
|
||||||
|
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
if isActive && coreContext.coreIsStarted {
|
if coreContext.coreIsStarted {
|
||||||
if !sharedMainViewModel.welcomeViewDisplayed {
|
if !sharedMainViewModel.welcomeViewDisplayed {
|
||||||
WelcomeView()
|
WelcomeView()
|
||||||
} else if coreContext.defaultAccount == nil || sharedMainViewModel.displayProfileMode {
|
} else if coreContext.defaultAccount == nil || sharedMainViewModel.displayProfileMode {
|
||||||
|
|
@ -52,7 +50,7 @@ struct LinphoneApp: App {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SplashScreen(isActive: $isActive)
|
SplashScreen()
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
contactViewModel = ContactViewModel()
|
contactViewModel = ContactViewModel()
|
||||||
editContactViewModel = EditContactViewModel()
|
editContactViewModel = EditContactViewModel()
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,9 @@
|
||||||
},
|
},
|
||||||
"Chiffrement de bout en bout de tous vos échanges, grâce au mode default vos communications sont à l’abri des regards." : {
|
"Chiffrement de bout en bout de tous vos échanges, grâce au mode default vos communications sont à l’abri des regards." : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Clear logs" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Close" : {
|
"Close" : {
|
||||||
|
|
||||||
|
|
@ -375,9 +378,6 @@
|
||||||
},
|
},
|
||||||
"Plus tard" : {
|
"Plus tard" : {
|
||||||
|
|
||||||
},
|
|
||||||
"Posts" : {
|
|
||||||
|
|
||||||
},
|
},
|
||||||
"Pour vous permettre de vous profitez pleinement de Linphone nous avons besoin des autorisations suivantes :" : {
|
"Pour vous permettre de vous profitez pleinement de Linphone nous avons besoin des autorisations suivantes :" : {
|
||||||
|
|
||||||
|
|
@ -408,6 +408,9 @@
|
||||||
},
|
},
|
||||||
"See Linphone contact" : {
|
"See Linphone contact" : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Send logs" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Share" : {
|
"Share" : {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ update_presence_model_timestamp_before_publish_expires_refresh=1
|
||||||
#Because dynamic bitrate adaption can increase bitrate, we must allow "no limit"
|
#Because dynamic bitrate adaption can increase bitrate, we must allow "no limit"
|
||||||
download_bw=0
|
download_bw=0
|
||||||
upload_bw=0
|
upload_bw=0
|
||||||
|
friendlist_subscription_enabled=1
|
||||||
|
|
||||||
[video]
|
[video]
|
||||||
size=vga
|
size=vga
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,6 @@ import SwiftUI
|
||||||
|
|
||||||
struct SplashScreen: View {
|
struct SplashScreen: View {
|
||||||
|
|
||||||
@ObservedObject private var coreContext = CoreContext.shared
|
|
||||||
@Binding var isActive: Bool
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
GeometryReader { _ in
|
GeometryReader { _ in
|
||||||
VStack {
|
VStack {
|
||||||
|
|
@ -42,5 +39,5 @@ struct SplashScreen: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
SplashScreen(isActive: .constant(true))
|
SplashScreen()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import linphonesw
|
||||||
|
import UniformTypeIdentifiers
|
||||||
|
|
||||||
struct SideMenu: View {
|
struct SideMenu: View {
|
||||||
|
|
||||||
|
@ObservedObject private var coreContext = CoreContext.shared
|
||||||
|
|
||||||
|
@State private var coreDelegate: CoreDelegate?
|
||||||
|
|
||||||
let width: CGFloat
|
let width: CGFloat
|
||||||
let isOpen: Bool
|
let isOpen: Bool
|
||||||
let menuClose: () -> Void
|
let menuClose: () -> Void
|
||||||
|
|
@ -41,8 +48,12 @@ struct SideMenu: View {
|
||||||
Text("My Profile").onTapGesture {
|
Text("My Profile").onTapGesture {
|
||||||
print("My Profile")
|
print("My Profile")
|
||||||
}
|
}
|
||||||
Text("Posts").onTapGesture {
|
Text("Send logs").onTapGesture {
|
||||||
print("Posts")
|
sendLogs()
|
||||||
|
}
|
||||||
|
Text("Clear logs").onTapGesture {
|
||||||
|
print("Clear logs")
|
||||||
|
Core.resetLogCollection()
|
||||||
}
|
}
|
||||||
Text("Logout").onTapGesture {
|
Text("Logout").onTapGesture {
|
||||||
print("Logout")
|
print("Logout")
|
||||||
|
|
@ -60,4 +71,42 @@ struct SideMenu: View {
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sendLogs() {
|
||||||
|
coreContext.doOnCoreQueue { core in
|
||||||
|
core.uploadLogCollection()
|
||||||
|
|
||||||
|
let newCoreDelegate = CoreDelegateStub(
|
||||||
|
onLogCollectionUploadStateChanged: { core, logCollectionUploadState, logString in
|
||||||
|
print("newCoreDelegatenewCoreDelegate \(logString)")
|
||||||
|
|
||||||
|
if logString.starts(with: "https") {
|
||||||
|
UIPasteboard.general.setValue(
|
||||||
|
logString,
|
||||||
|
forPasteboardType: UTType.plainText.identifier
|
||||||
|
)
|
||||||
|
|
||||||
|
removeAllDelegate()
|
||||||
|
|
||||||
|
ToastViewModel.shared.toastMessage = "Success_copied_into_clipboard"
|
||||||
|
ToastViewModel.shared.displayToast.toggle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
coreDelegate = newCoreDelegate
|
||||||
|
if coreDelegate != nil {
|
||||||
|
core.addDelegate(delegate: coreDelegate!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeAllDelegate() {
|
||||||
|
coreContext.doOnCoreQueue { core in
|
||||||
|
if coreDelegate != nil {
|
||||||
|
core.removeDelegate(delegate: coreDelegate!)
|
||||||
|
coreDelegate = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue