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 {
|
||||
self.linphoneFriendList = try core.getFriendListByName(name: self.linphoneAddressBookFriendList) ?? core.createFriendList()
|
||||
|
||||
//self.linphoneFriendList?.updateSubscriptions()
|
||||
print("friendListfriendListfriendListfriendList \(self.linphoneFriendList!.rlsAddress)")
|
||||
} catch let error {
|
||||
print("\(#function) - Failed to enumerate contacts: \(error)")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ final class CoreContext: ObservableObject {
|
|||
|
||||
coreQueue.async {
|
||||
let configDir = Factory.Instance.getConfigDir(context: nil)
|
||||
|
||||
Factory.Instance.logCollectionPath = configDir
|
||||
Factory.Instance.enableLogCollection(state: LogCollectionState.Enabled)
|
||||
|
||||
let url = NSURL(fileURLWithPath: configDir)
|
||||
if let pathComponent = url.appendingPathComponent("linphonerc") {
|
||||
let filePath = pathComponent.path
|
||||
|
|
@ -71,25 +75,32 @@ final class CoreContext: ObservableObject {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
let config: Config! = Config.newForSharedCore(
|
||||
appGroupId: "group.org.linphone.phone.msgNotification",
|
||||
configFilename: "linphonerc",
|
||||
factoryConfigFilename: Bundle.main.path(forResource: "linphonerc-factory", ofType: nil)
|
||||
)
|
||||
|
||||
self.mCore = try? Factory.Instance.createCoreWithConfig(config: config, systemContext: nil)
|
||||
|
||||
let config = try? Factory.Instance.createConfigWithFactory(
|
||||
path: "\(configDir)/linphonerc",
|
||||
factoryPath: Bundle.main.path(forResource: "linphonerc-factory", ofType: nil)
|
||||
)
|
||||
if config != nil {
|
||||
self.mCore = try? Factory.Instance.createCoreWithConfig(config: config!, systemContext: nil)
|
||||
}
|
||||
|
||||
self.mCore.autoIterateEnabled = false
|
||||
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
|
||||
if cbVal.state == GlobalState.On {
|
||||
self.defaultAccount = self.mCore.defaultAccount
|
||||
} else if cbVal.state == GlobalState.Off {
|
||||
self.defaultAccount = nil
|
||||
}
|
||||
self.coreIsStarted = true
|
||||
}
|
||||
|
||||
try? self.mCore.start()
|
||||
|
||||
// Create a Core listener to listen for the callback we need
|
||||
|
|
@ -115,7 +126,6 @@ final class CoreContext: ObservableObject {
|
|||
if cbVal.state == .Ok {
|
||||
self.loggingInProgress = false
|
||||
self.loggedIn = true
|
||||
self.coreIsStarted = true
|
||||
} else if cbVal.state == .Progress {
|
||||
self.loggingInProgress = true
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -30,11 +30,9 @@ struct LinphoneApp: App {
|
|||
@State private var historyViewModel: HistoryViewModel?
|
||||
@State private var historyListViewModel: HistoryListViewModel?
|
||||
|
||||
@State private var isActive = true
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
if isActive && coreContext.coreIsStarted {
|
||||
if coreContext.coreIsStarted {
|
||||
if !sharedMainViewModel.welcomeViewDisplayed {
|
||||
WelcomeView()
|
||||
} else if coreContext.defaultAccount == nil || sharedMainViewModel.displayProfileMode {
|
||||
|
|
@ -52,7 +50,7 @@ struct LinphoneApp: App {
|
|||
)
|
||||
}
|
||||
} else {
|
||||
SplashScreen(isActive: $isActive)
|
||||
SplashScreen()
|
||||
.onDisappear {
|
||||
contactViewModel = ContactViewModel()
|
||||
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." : {
|
||||
|
||||
},
|
||||
"Clear logs" : {
|
||||
|
||||
},
|
||||
"Close" : {
|
||||
|
||||
|
|
@ -375,9 +378,6 @@
|
|||
},
|
||||
"Plus tard" : {
|
||||
|
||||
},
|
||||
"Posts" : {
|
||||
|
||||
},
|
||||
"Pour vous permettre de vous profitez pleinement de Linphone nous avons besoin des autorisations suivantes :" : {
|
||||
|
||||
|
|
@ -408,6 +408,9 @@
|
|||
},
|
||||
"See Linphone contact" : {
|
||||
|
||||
},
|
||||
"Send logs" : {
|
||||
|
||||
},
|
||||
"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"
|
||||
download_bw=0
|
||||
upload_bw=0
|
||||
friendlist_subscription_enabled=1
|
||||
|
||||
[video]
|
||||
size=vga
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ import SwiftUI
|
|||
|
||||
struct SplashScreen: View {
|
||||
|
||||
@ObservedObject private var coreContext = CoreContext.shared
|
||||
@Binding var isActive: Bool
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { _ in
|
||||
VStack {
|
||||
|
|
@ -42,5 +39,5 @@ struct SplashScreen: View {
|
|||
}
|
||||
|
||||
#Preview {
|
||||
SplashScreen(isActive: .constant(true))
|
||||
SplashScreen()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,15 @@
|
|||
*/
|
||||
|
||||
import SwiftUI
|
||||
import linphonesw
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
struct SideMenu: View {
|
||||
|
||||
@ObservedObject private var coreContext = CoreContext.shared
|
||||
|
||||
@State private var coreDelegate: CoreDelegate?
|
||||
|
||||
let width: CGFloat
|
||||
let isOpen: Bool
|
||||
let menuClose: () -> Void
|
||||
|
|
@ -41,9 +48,13 @@ struct SideMenu: View {
|
|||
Text("My Profile").onTapGesture {
|
||||
print("My Profile")
|
||||
}
|
||||
Text("Posts").onTapGesture {
|
||||
print("Posts")
|
||||
Text("Send logs").onTapGesture {
|
||||
sendLogs()
|
||||
}
|
||||
Text("Clear logs").onTapGesture {
|
||||
print("Clear logs")
|
||||
Core.resetLogCollection()
|
||||
}
|
||||
Text("Logout").onTapGesture {
|
||||
print("Logout")
|
||||
}
|
||||
|
|
@ -60,4 +71,42 @@ struct SideMenu: View {
|
|||
}
|
||||
.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