Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
BC
public
tutorials
Commits
2a1b1aaa
Commit
2a1b1aaa
authored
3 years ago
by
jehan
Browse files
Options
Download
Patches
Plain Diff
premier commentaires
parent
3f09bddb
dev/swift_revue
1 merge request
!7
premier commentaires
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
swift/LoginTutorial/LoginTutorial/ContentView.swift
+1
-1
swift/LoginTutorial/LoginTutorial/ContentView.swift
swift/LoginTutorial/LoginTutorial/LoginExample.swift
+9
-6
swift/LoginTutorial/LoginTutorial/LoginExample.swift
swift/LoginTutorial/Podfile
+1
-1
swift/LoginTutorial/Podfile
swift/TutorialCommons/commons.swift
+18
-28
swift/TutorialCommons/commons.swift
with
29 additions
and
36 deletions
swift/LoginTutorial/LoginTutorial/ContentView.swift
+
1
−
1
View file @
2a1b1aaa
...
...
@@ -60,7 +60,7 @@ struct ContentView: View {
}
Group
{
Spacer
()
Toggle
(
isOn
:
$
tutorialContext
.
loggingUnit
.
logsEnabled
.
value
)
{
Toggle
(
isOn
:
$
tutorialContext
.
loggingUnit
.
logsEnabled
)
{
Text
(
"Logs collection"
)
.
multilineTextAlignment
(
.
trailing
)
}
...
...
This diff is collapsed.
Click to expand it.
swift/LoginTutorial/LoginTutorial/LoginExample.swift
+
9
−
6
View file @
2a1b1aaa
...
...
@@ -27,12 +27,15 @@ class LoginTutorialContext : ObservableObject
init
()
{
// Initialize Linphone Core
try
?
mCore
=
Factory
.
Instance
.
createCore
(
configPath
:
""
,
factoryConfigPath
:
""
,
systemContext
:
nil
)
//FIXME ne peut on avoir une fonction de création sans param plutot que des params vide ?
try
?
mCore
=
Factory
.
Instance
.
createCore
(
configPath
:
nil
,
factoryConfigPath
:
nil
,
systemContext
:
nil
)
// main loop for receiving notifications and doing background linphonecore work:
mCore
.
autoIterateEnabled
=
true
//FIXME plus necessaire en 5.0
mCore
.
autoIterateEnabled
=
true
try
?
mCore
.
start
()
// Add callbacks to the Linphone Core
//pourquoi un attribue de class ? une variable locale serait sufisante.
mRegistrationDelegate
=
CoreDelegateStub
(
onAccountRegistrationStateChanged
:
{
(
core
:
Core
,
account
:
Account
,
state
:
RegistrationState
,
message
:
String
)
in
print
(
"New registration state
\(
state
)
for user id
\(
String
(
describing
:
account
.
params
?
.
identityAddress
?
.
asString
())
)\n
"
)
if
(
state
==
.
Ok
)
{
...
...
@@ -45,6 +48,8 @@ class LoginTutorialContext : ObservableObject
mCore
.
addDelegate
(
delegate
:
mRegistrationDelegate
)
}
//FIXME expliquer ce que ça fait
func
registrationExample
()
{
if
(
!
loggedIn
)
{
...
...
@@ -52,10 +57,8 @@ class LoginTutorialContext : ObservableObject
if
(
account
==
nil
)
{
account
=
try
createAndInitializeAccount
(
core
:
mCore
,
identity
:
id
,
password
:
passwd
)
try
mCore
.
addAccount
(
account
:
account
!
)
if
(
mCore
.
defaultAccount
==
nil
)
{
// IMPORTANT : default account setting MUST be done AFTER adding the config to the core !)
mCore
.
defaultAccount
=
account
}
// IMPORTANT : default account setting MUST be done AFTER adding the config to the core !)
mCore
.
defaultAccount
=
account
}
else
{
let
registeredParams
=
account
?
.
params
?
.
clone
()
...
...
This diff is collapsed.
Click to expand it.
swift/LoginTutorial/Podfile
+
1
−
1
View file @
2a1b1aaa
...
...
@@ -5,7 +5,7 @@ source "https://gitlab.linphone.org/BC/public/podspec.git"
def
basic_pods
if
ENV
[
'PODFILE_PATH'
].
nil?
pod
'linphone-sdk'
,
'~> 5.0.0
-alpha
'
pod
'linphone-sdk'
,
'~> 5.0.0'
else
pod
'linphone-sdk'
,
:path
=>
ENV
[
'PODFILE_PATH'
]
# local sdk
end
...
...
This diff is collapsed.
Click to expand it.
swift/TutorialCommons/commons.swift
+
18
−
28
View file @
2a1b1aaa
//FIXME GPL
// Created by QuentinArguillere on 17/08/2020.
// Copyright © 2020 BelledonneCommunications. All rights reserved.
//
...
...
@@ -5,20 +7,21 @@
import
Foundation
import
linphonesw
//FIXME expliquer
func
createAndInitializeAccount
(
core
:
Core
,
identity
:
String
,
password
:
String
,
withVoipPush
:
Bool
=
false
,
withRemotePush
:
Bool
=
false
)
throws
->
Account
{
let
factory
=
Factory
.
Instance
let
accountParams
=
try
core
.
createAccountParams
()
let
address
=
try
factory
.
createAddress
(
addr
:
identity
)
let
info
=
try
factory
.
createAuthInfo
(
username
:
address
.
username
,
userid
:
""
,
passwd
:
password
,
ha1
:
""
,
realm
:
""
,
domain
:
address
.
domain
)
let
info
=
try
factory
.
createAuthInfo
(
username
:
address
.
username
,
userid
:
nil
,
passwd
:
password
,
ha1
:
nil
,
realm
:
nil
,
domain
:
address
.
domain
)
try
accountParams
.
setIdentityaddress
(
newValue
:
address
)
try
accountParams
.
setServeraddr
(
newValue
:
"sip:"
+
address
.
domain
+
";transport=t
ls
"
)
try
accountParams
.
setServeraddr
(
newValue
:
"sip:"
+
address
.
domain
+
";transport=t
cp
"
)
accountParams
.
registerEnabled
=
true
// This is necessary to register to the server and handle push Notifications. Make sure you have a certificate to match your app's bundle ID.
accountParams
.
pushNotificationConfig
?
.
provider
=
"apns.dev"
//FIXME + de coomtaires
accountParams
.
pushNotificationAllowed
=
withVoipPush
accountParams
.
remotePushNotificationAllowed
=
withRemotePush
core
.
addAuthInfo
(
info
:
info
)
...
...
@@ -28,35 +31,22 @@ func createAndInitializeAccount(core: Core, identity: String, password: String,
class
LoggingUnit
{
class
BoolHolder
:
ObservableObject
{
@Published
var
value
:
Bool
init
(
val
:
Bool
)
{
value
=
val
}
}
var
logsEnabled
:
BoolHolder
var
logDelegate
:
LinphoneLoggingServiceImpl
var
log
:
LoggingService
var
logsEnabled
:
Bool
=
true
{
didSet
{
LoggingService
.
Instance
.
logLevel
=
logsEnabled
?
LogLevel
.
Debug
:
LogLevel
.
Fatal
}
}
class
LinphoneLoggingServiceImpl
:
LoggingServiceDelegate
{
var
logsEnabled
:
BoolHolder
!
func
onLogMessageWritten
(
logService
:
LoggingService
,
domain
:
String
,
level
:
LogLevel
,
message
:
String
)
{
if
(
logsEnabled
.
value
)
{
print
(
"Linphone logs:
\(
message
)
"
)
}
print
(
"Linphone logs:
\(
message
)
"
)
}
}
init
()
{
logsEnabled
=
BoolHolder
(
val
:
true
)
logDelegate
=
LinphoneLoggingServiceImpl
()
logDelegate
.
logsEnabled
=
logsEnabled
;
log
=
LoggingService
.
Instance
log
.
addDelegate
(
delegate
:
logDelegate
)
log
.
logLevel
=
LogLevel
.
Debug
Factory
.
Instance
.
enableLogCollection
(
state
:
LogCollectionState
.
Enabled
)
init
()
{
//FIXME commentaires
LoggingService
.
Instance
.
addDelegate
(
delegate
:
LinphoneLoggingServiceImpl
())
LoggingService
.
Instance
.
logLevel
=
LogLevel
.
Debug
}
}
This diff is collapsed.
Click to expand it.
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets