@@ -21,7 +21,7 @@ import net.syncthing.java.client.protocol.rp.RelayClient
21
21
import net.syncthing.java.core.beans.DeviceAddress
22
22
import net.syncthing.java.core.beans.DeviceId
23
23
import net.syncthing.java.core.beans.FolderInfo
24
- import net.syncthing.java.core.configuration.ConfigurationService
24
+ import net.syncthing.java.core.configuration.Configuration
25
25
import net.syncthing.java.core.security.KeystoreHandler
26
26
import net.syncthing.java.core.utils.NetworkUtils
27
27
import net.syncthing.java.core.utils.submitLogging
@@ -43,7 +43,7 @@ import java.util.concurrent.Future
43
43
import java.util.concurrent.TimeUnit
44
44
import javax.net.ssl.SSLSocket
45
45
46
- class BlockExchangeConnectionHandler (private val configuration : ConfigurationService , val address : DeviceAddress ,
46
+ class BlockExchangeConnectionHandler (private val configuration : Configuration , val address : DeviceAddress ,
47
47
private val indexHandler : IndexHandler ,
48
48
private val onDeviceAddressActiveListener : (DeviceId ) -> Unit ,
49
49
private val onNewFolderSharedListener : (FolderInfo ) -> Unit ,
@@ -64,10 +64,8 @@ class BlockExchangeConnectionHandler(private val configuration: ConfigurationSer
64
64
private val blockPuller = BlockPuller (configuration, this )
65
65
private val blockPusher = BlockPusher (configuration, this , indexHandler)
66
66
private val onRequestMessageReceivedListeners = mutableSetOf< (Request ) -> Unit > ()
67
- var isClosed = false
68
- private set
69
- var isConnected = false
70
- private set
67
+ private var isClosed = false
68
+ private var isConnected = false
71
69
72
70
fun deviceId (): DeviceId = address.deviceId()
73
71
@@ -90,7 +88,7 @@ class BlockExchangeConnectionHandler(private val configuration: ConfigurationSer
90
88
assert (socket == null && ! isConnected, {" already connected!" })
91
89
logger.info(" connecting to {}" , address.address)
92
90
93
- val keystoreHandler = KeystoreHandler .Loader ().loadAndStore (configuration)
91
+ val keystoreHandler = KeystoreHandler .Loader ().loadKeystore (configuration)
94
92
95
93
socket = when (address.getType()) {
96
94
DeviceAddress .AddressType .TCP -> {
@@ -111,9 +109,9 @@ class BlockExchangeConnectionHandler(private val configuration: ConfigurationSer
111
109
outputStream = DataOutputStream (socket!! .getOutputStream())
112
110
113
111
sendHelloMessage(BlockExchangeProtos .Hello .newBuilder()
114
- .setClientName(configuration.getClientName() )
112
+ .setClientName(configuration.clientName )
115
113
.setClientVersion(configuration.clientVersion)
116
- .setDeviceName(configuration.deviceName )
114
+ .setDeviceName(configuration.localDeviceName )
117
115
.build().toByteArray())
118
116
markActivityOnSocket()
119
117
@@ -127,12 +125,12 @@ class BlockExchangeConnectionHandler(private val configuration: ConfigurationSer
127
125
128
126
run {
129
127
val clusterConfigBuilder = ClusterConfig .newBuilder()
130
- for (folder in configuration.getFolderNames() ) {
128
+ for (folder in configuration.folderNames ) {
131
129
val folderBuilder = Folder .newBuilder().setId(folder)
132
130
run {
133
131
// our device
134
132
val deviceBuilder = Device .newBuilder()
135
- .setId(ByteString .copyFrom(configuration.deviceId !! .toHashData()))
133
+ .setId(ByteString .copyFrom(configuration.localDeviceId .toHashData()))
136
134
.setIndexId(indexHandler.sequencer().indexId())
137
135
.setMaxSequence(indexHandler.sequencer().currentSequence())
138
136
folderBuilder.addDevices(deviceBuilder)
@@ -173,7 +171,7 @@ class BlockExchangeConnectionHandler(private val configuration: ConfigurationSer
173
171
throw IOException (" unable to retrieve cluster config from peer!" )
174
172
}
175
173
}
176
- for (folder in configuration.getFolderNames() ) {
174
+ for (folder in configuration.folderNames ) {
177
175
if (hasFolder(folder)) {
178
176
sendIndexMessage(folder)
179
177
}
@@ -407,16 +405,16 @@ class BlockExchangeConnectionHandler(private val configuration: ConfigurationSer
407
405
DeviceId .fromHashData(input.id!! .toByteArray())
408
406
}
409
407
val otherDevice = devicesById[address.deviceId()]
410
- val ourDevice = devicesById[configuration.deviceId ]
408
+ val ourDevice = devicesById[configuration.localDeviceId ]
411
409
if (otherDevice != null ) {
412
410
folderInfo.isAnnounced = true
413
411
}
414
412
if (ourDevice != null ) {
415
413
folderInfo.isShared = true
416
414
logger.info(" folder shared from device = {} folder = {}" , address.deviceId, folderInfo)
417
- if (! configuration.getFolderNames() .contains(folderInfo.folder)) {
415
+ if (! configuration.folderNames .contains(folderInfo.folder)) {
418
416
val fi = FolderInfo (folderInfo.folder, folderInfo.label)
419
- configuration.Editor ().addFolders( setOf (fi))
417
+ configuration.folders = configuration.folders + fi
420
418
onNewFolderSharedListener(fi)
421
419
logger.info(" new folder shared = {}" , folderInfo)
422
420
}
@@ -425,7 +423,7 @@ class BlockExchangeConnectionHandler(private val configuration: ConfigurationSer
425
423
}
426
424
clusterConfigInfo!! .putFolderInfo(folderInfo)
427
425
}
428
- configuration.Editor (). persistLater()
426
+ configuration.persistLater()
429
427
indexHandler.handleClusterConfigMessageProcessedEvent(clusterConfig)
430
428
onDeviceAddressActive()
431
429
synchronized(clusterConfigWaitingLock) {
0 commit comments