mirror of
https://github.com/etesync/android
synced 2025-02-22 12:32:03 +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 {
|
fun findInitialConfiguration(): Configuration {
|
||||||
var exception: Throwable? = null
|
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())
|
val uri = credentials.uri ?: URI(Constants.serviceUrl.toString())
|
||||||
|
|
||||||
@ -60,26 +58,17 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
|
|||||||
return Configuration(
|
return Configuration(
|
||||||
uri,
|
uri,
|
||||||
credentials.userName, authtoken,
|
credentials.userName, authtoken,
|
||||||
cardDavConfig, calDavConfig,
|
|
||||||
userInfo,
|
userInfo,
|
||||||
exception
|
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
|
// data classes
|
||||||
|
|
||||||
class Configuration
|
class Configuration
|
||||||
// We have to use URI here because HttpUrl is not serializable!
|
// 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 rawPassword: String? = null
|
||||||
var password: String? = null
|
var password: String? = null
|
||||||
var keyPair: Crypto.AsymmetricKeyPair? = null
|
var keyPair: Crypto.AsymmetricKeyPair? = null
|
||||||
@ -96,7 +85,7 @@ class BaseConfigurationFinder(protected val context: Context, protected val cred
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
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
|
// 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
|
// contact sync is automatically enabled by isAlwaysSyncable="true" in res/xml/sync_contacts.xml
|
||||||
settings.setSyncInterval(App.addressBooksAuthority, Constants.DEFAULT_SYNC_INTERVAL.toLong())
|
settings.setSyncInterval(App.addressBooksAuthority, Constants.DEFAULT_SYNC_INTERVAL.toLong())
|
||||||
|
|
||||||
// insert CalDAV service
|
// 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
|
// calendar sync is automatically enabled by isAlwaysSyncable="true" in res/xml/sync_contacts.xml
|
||||||
settings.setSyncInterval(CalendarContract.AUTHORITY, Constants.DEFAULT_SYNC_INTERVAL.toLong())
|
settings.setSyncInterval(CalendarContract.AUTHORITY, Constants.DEFAULT_SYNC_INTERVAL.toLong())
|
||||||
@ -160,8 +160,9 @@ class SetupEncryptionFragment : DialogFragment() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun insertService(accountName: String, serviceType: CollectionInfo.Type, info: BaseConfigurationFinder.Configuration.ServiceInfo) {
|
protected fun insertService(accountName: String, serviceType: CollectionInfo.Type) {
|
||||||
val data = (context!!.applicationContext as App).data
|
val info = Configuration.ServiceInfo()
|
||||||
|
val data = (requireContext().applicationContext as App).data
|
||||||
|
|
||||||
// insert service
|
// insert service
|
||||||
val serviceEntity = ServiceEntity.fetchOrCreate(data, accountName, serviceType)
|
val serviceEntity = ServiceEntity.fetchOrCreate(data, accountName, serviceType)
|
||||||
|
Loading…
Reference in New Issue
Block a user