File tree Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change 66
77import Foundation
88import ReadiumShared
9+ import UIKit
910
1011/// Service used to acquire and open publications protected with LCP.
1112///
@@ -20,7 +21,13 @@ public final class LCPService: Loggable {
2021 private let licenses : LicensesService
2122 private let passphrases : PassphrasesRepository
2223
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+ ) {
2431 // Determine whether the embedded liblcp.a is in production mode, by attempting to open a production license.
2532 let isProduction : Bool = {
2633 guard
@@ -40,7 +47,11 @@ public final class LCPService: Loggable {
4047 client: client,
4148 licenses: db. licenses,
4249 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+ ) ,
4455 httpClient: httpClient,
4556 passphrases: PassphrasesService ( client: client, repository: passphrases)
4657 )
Original file line number Diff line number Diff line change 66
77import Foundation
88import ReadiumShared
9- import UIKit
109
1110final class DeviceService {
1211 private let repository : DeviceRepository
1312 private let httpClient : HTTPClient
1413
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
1623 self . repository = repository
1724 self . httpClient = httpClient
1825 }
@@ -28,11 +35,6 @@ final class DeviceService {
2835 return deviceId
2936 }
3037
31- // Returns the device's name.
32- var name : String {
33- UIDevice . current. name
34- }
35-
3638 // Device ID and name as query parameters for HTTP requests.
3739 var asQueryParameters : [ String : String ] {
3840 [
You can’t perform that action at this time.
0 commit comments