mirror of
https://github.com/etesync/android
synced 2024-11-15 20:38:58 +00:00
Simplify Configuration class - caldav/carddav aren't required.
This commit is contained in:
parent
feed7c2119
commit
476f756307
@ -34,8 +34,6 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
|
||||
|
||||
fun findInitialConfiguration(): Configuration {
|
||||
var exception: Throwable? = null
|
||||
val cardDavConfig = findInitialConfiguration(CollectionInfo.Type.ADDRESS_BOOK)
|
||||
val calDavConfig = findInitialConfiguration(CollectionInfo.Type.CALENDAR)
|
||||
|
||||
val uri = credentials.uri ?: URI(Constants.serviceUrl.toString())
|
||||
|
||||
@ -60,26 +58,17 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
|
||||
return Configuration(
|
||||
uri,
|
||||
credentials.userName, authtoken,
|
||||
cardDavConfig, calDavConfig,
|
||||
userInfo,
|
||||
exception
|
||||
)
|
||||
}
|
||||
|
||||
protected fun findInitialConfiguration(service: CollectionInfo.Type): Configuration.ServiceInfo {
|
||||
// put discovered information here
|
||||
val config = Configuration.ServiceInfo()
|
||||
Logger.log.info("Finding initial " + service.toString() + " service configuration")
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
// data classes
|
||||
|
||||
class Configuration
|
||||
// We have to use URI here because HttpUrl is not serializable!
|
||||
|
||||
(val url: URI, val userName: String, val authtoken: String?, val cardDAV: ServiceInfo, val calDAV: ServiceInfo, var userInfo: UserInfoManager.UserInfo?, var error: Throwable?) : Serializable {
|
||||
(val url: URI, val userName: String, val authtoken: String?, var userInfo: UserInfoManager.UserInfo?, var error: Throwable?) : Serializable {
|
||||
var rawPassword: String? = null
|
||||
var password: String? = null
|
||||
var keyPair: Crypto.AsymmetricKeyPair? = null
|
||||
@ -96,7 +85,7 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "BaseConfigurationFinder.Configuration(url=" + this.url + ", userName=" + this.userName + ", keyPair=" + this.keyPair + ", cardDAV=" + this.cardDAV + ", calDAV=" + this.calDAV + ", error=" + this.error + ", failed=" + this.isFailed + ")"
|
||||
return "BaseConfigurationFinder.Configuration(url=" + this.url + ", userName=" + this.userName + ", keyPair=" + this.keyPair + ", error=" + this.error + ", failed=" + this.isFailed + ")"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,13 +134,13 @@ class SetupEncryptionFragment : DialogFragment() {
|
||||
}
|
||||
|
||||
// insert CardDAV service
|
||||
insertService(accountName, CollectionInfo.Type.ADDRESS_BOOK, config.cardDAV)
|
||||
insertService(accountName, CollectionInfo.Type.ADDRESS_BOOK)
|
||||
|
||||
// contact sync is automatically enabled by isAlwaysSyncable="true" in res/xml/sync_contacts.xml
|
||||
settings.setSyncInterval(App.addressBooksAuthority, Constants.DEFAULT_SYNC_INTERVAL.toLong())
|
||||
|
||||
// insert CalDAV service
|
||||
insertService(accountName, CollectionInfo.Type.CALENDAR, config.calDAV)
|
||||
insertService(accountName, CollectionInfo.Type.CALENDAR)
|
||||
|
||||
// calendar sync is automatically enabled by isAlwaysSyncable="true" in res/xml/sync_contacts.xml
|
||||
settings.setSyncInterval(CalendarContract.AUTHORITY, Constants.DEFAULT_SYNC_INTERVAL.toLong())
|
||||
@ -160,8 +160,9 @@ class SetupEncryptionFragment : DialogFragment() {
|
||||
return true
|
||||
}
|
||||
|
||||
protected fun insertService(accountName: String, serviceType: CollectionInfo.Type, info: BaseConfigurationFinder.Configuration.ServiceInfo) {
|
||||
val data = (context!!.applicationContext as App).data
|
||||
protected fun insertService(accountName: String, serviceType: CollectionInfo.Type) {
|
||||
val info = Configuration.ServiceInfo()
|
||||
val data = (requireContext().applicationContext as App).data
|
||||
|
||||
// insert service
|
||||
val serviceEntity = ServiceEntity.fetchOrCreate(data, accountName, serviceType)
|
||||
|
Loading…
Reference in New Issue
Block a user