File tree 2 files changed +22
-9
lines changed
2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change 6
6
7
7
import Foundation
8
8
import ReadiumShared
9
+ import UIKit
9
10
10
11
/// Service used to acquire and open publications protected with LCP.
11
12
///
@@ -20,7 +21,13 @@ public final class LCPService: Loggable {
20
21
private let licenses : LicensesService
21
22
private let passphrases : PassphrasesRepository
22
23
23
- public init ( client: LCPClient , httpClient: HTTPClient = DefaultHTTPClient ( ) ) {
24
+ /// - Parameter deviceName: Device name used when registering a license to an LSD server.
25
+ /// If not provided, the device name will be the default `UIDevice.current.name`.
26
+ public init (
27
+ client: LCPClient ,
28
+ httpClient: HTTPClient = DefaultHTTPClient ( ) ,
29
+ deviceName: String ? = nil
30
+ ) {
24
31
// Determine whether the embedded liblcp.a is in production mode, by attempting to open a production license.
25
32
let isProduction : Bool = {
26
33
guard
@@ -40,7 +47,11 @@ public final class LCPService: Loggable {
40
47
client: client,
41
48
licenses: db. licenses,
42
49
crl: CRLService ( httpClient: httpClient) ,
43
- device: DeviceService ( repository: db. licenses, httpClient: httpClient) ,
50
+ device: DeviceService (
51
+ deviceName: deviceName ?? UIDevice . current. name,
52
+ repository: db. licenses,
53
+ httpClient: httpClient
54
+ ) ,
44
55
httpClient: httpClient,
45
56
passphrases: PassphrasesService ( client: client, repository: passphrases)
46
57
)
Original file line number Diff line number Diff line change 6
6
7
7
import Foundation
8
8
import ReadiumShared
9
- import UIKit
10
9
11
10
final class DeviceService {
12
11
private let repository : DeviceRepository
13
12
private let httpClient : HTTPClient
14
13
15
- init ( repository: DeviceRepository , httpClient: HTTPClient ) {
14
+ /// Returns the device's name.
15
+ var name : String
16
+
17
+ init (
18
+ deviceName: String ,
19
+ repository: DeviceRepository ,
20
+ httpClient: HTTPClient
21
+ ) {
22
+ name = deviceName
16
23
self . repository = repository
17
24
self . httpClient = httpClient
18
25
}
@@ -28,11 +35,6 @@ final class DeviceService {
28
35
return deviceId
29
36
}
30
37
31
- // Returns the device's name.
32
- var name : String {
33
- UIDevice . current. name
34
- }
35
-
36
38
// Device ID and name as query parameters for HTTP requests.
37
39
var asQueryParameters : [ String : String ] {
38
40
[
You can’t perform that action at this time.
0 commit comments