Loading app/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -142,6 +142,7 @@ dependencies { implementation 'org.apache.commons:commons-collections4:4.4' implementation 'org.apache.commons:commons-lang3:3.9' implementation 'net.openid:appauth:0.7.0' implementation 'com.google.android.material:material:1.0.0' // for tests androidTestImplementation 'androidx.test:runner:1.2.0' Loading app/src/main/java/foundation/e/accountmanager/DavService.kt +8 −5 Original line number Diff line number Diff line Loading @@ -273,12 +273,16 @@ class DavService: android.app.Service() { .build().use { client -> val httpClient = client.okHttpClient val authState = service.authState var authState : String? = null service.authState?.let { authstate -> authState = AuthState.jsonDeserialize(authstate).accessToken } // refresh home set list (from principal) service.principal?.let { principalUrl -> Logger.log.fine("Querying principal $principalUrl for home sets") queryHomeSets(httpClient, principalUrl, AuthState.jsonDeserialize(authState).accessToken) queryHomeSets(httpClient, principalUrl, authState) } // now refresh homesets and their member collections Loading @@ -288,7 +292,7 @@ class DavService: android.app.Service() { Logger.log.fine("Listing home set ${homeSet.key}") try { DavResource(httpClient, homeSet.key, AuthState.jsonDeserialize(authState).accessToken).propfind(1, *DAV_COLLECTION_PROPERTIES) { response, relation -> DavResource(httpClient, homeSet.key, authState).propfind(1, *DAV_COLLECTION_PROPERTIES) { response, relation -> if (!response.isSuccess()) return@propfind Loading Loading @@ -322,7 +326,7 @@ class DavService: android.app.Service() { val (url, info) = itCollections.next() if (!info.confirmed) try { DavResource(httpClient, url, AuthState.jsonDeserialize(authState).accessToken).propfind(0, *DAV_COLLECTION_PROPERTIES) { response, _ -> DavResource(httpClient, url, authState).propfind(0, *DAV_COLLECTION_PROPERTIES) { response, _ -> if (!response.isSuccess()) return@propfind Loading @@ -345,7 +349,6 @@ class DavService: android.app.Service() { } } saveResults() } catch(e: InvalidAccountException) { Loading app/src/main/java/foundation/e/accountmanager/model/Service.kt +1 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ data class Service( var accountName: String, var authState: String, var authState: String?, var accountType: String, var addressBookAccountType: String, Loading app/src/main/java/foundation/e/accountmanager/ui/setup/AccountDetailsFragment.kt +7 −7 Original line number Diff line number Diff line Loading @@ -201,7 +201,7 @@ class AccountDetailsFragment: Fragment() { if (config.cardDAV != null) { // insert CardDAV service val id = insertService(db, name, credentials.authState!!.jsonSerializeString(), accountType, addressBookAccountType, Service.TYPE_CARDDAV, config.cardDAV) val id = insertService(db, name, credentials.authState?.jsonSerializeString(), accountType, addressBookAccountType, Service.TYPE_CARDDAV, config.cardDAV) // initial CardDAV account settings accountSettings.setGroupMethod(groupMethod) Loading @@ -217,7 +217,7 @@ class AccountDetailsFragment: Fragment() { if (config.calDAV != null) { // insert CalDAV service val id = insertService(db, name, credentials.authState!!.jsonSerializeString(), accountType, addressBookAccountType, Service.TYPE_CALDAV, config.calDAV) val id = insertService(db, name, credentials.authState?.jsonSerializeString(), accountType, addressBookAccountType, Service.TYPE_CALDAV, config.calDAV) // start CalDAV service detection (refresh collections) refreshIntent.putExtra(DavService.EXTRA_DAV_SERVICE_ID, id) Loading Loading @@ -247,7 +247,7 @@ class AccountDetailsFragment: Fragment() { return result } private fun insertService(db: AppDatabase, accountName: String, authState: String, accountType: String, addressBookAccountType: String, type: String, info: DavResourceFinder.Configuration.ServiceInfo): Long { private fun insertService(db: AppDatabase, accountName: String, authState: String?, accountType: String, addressBookAccountType: String, type: String, info: DavResourceFinder.Configuration.ServiceInfo): Long { // insert service val service = Service(0, accountName, authState, accountType, addressBookAccountType, type, info.principal) val serviceId = db.serviceDao().insertOrReplace(service) Loading app/src/main/java/foundation/e/accountmanager/ui/setup/DavResourceFinder.kt +3 −3 Original line number Diff line number Diff line Loading @@ -173,7 +173,7 @@ class DavResourceFinder( private fun checkUserGivenURL(baseURL: HttpUrl, service: Service, config: Configuration.ServiceInfo) { log.info("Checking user-given URL: $baseURL") val davBase = DavResource(httpClient.okHttpClient, baseURL, loginModel.credentials!!.authState!!.accessToken, log) val davBase = DavResource(httpClient.okHttpClient, baseURL, loginModel.credentials?.authState?.accessToken, log) try { when (service) { Service.CARDDAV -> { Loading Loading @@ -296,7 +296,7 @@ class DavResourceFinder( fun providesService(url: HttpUrl, service: Service): Boolean { var provided = false try { DavResource(httpClient.okHttpClient, url, loginModel.credentials!!.authState!!.accessToken, log).options { capabilities, _ -> DavResource(httpClient.okHttpClient, url, loginModel.credentials?.authState?.accessToken, log).options { capabilities, _ -> if ((service == Service.CARDDAV && capabilities.contains("addressbook")) || (service == Service.CALDAV && capabilities.contains("calendar-access"))) provided = true Loading Loading @@ -382,7 +382,7 @@ class DavResourceFinder( @Throws(IOException::class, HttpException::class, DavException::class) fun getCurrentUserPrincipal(url: HttpUrl, service: Service?): HttpUrl? { var principal: HttpUrl? = null DavResource(httpClient.okHttpClient, url, loginModel.credentials!!.authState!!.accessToken, log).propfind(0, CurrentUserPrincipal.NAME) { response, _ -> DavResource(httpClient.okHttpClient, url, loginModel.credentials?.authState?.accessToken, log).propfind(0, CurrentUserPrincipal.NAME) { response, _ -> response[CurrentUserPrincipal::class.java]?.href?.let { href -> response.requestedUrl.resolve(href)?.let { log.info("Found current-user-principal: $it") Loading Loading
app/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -142,6 +142,7 @@ dependencies { implementation 'org.apache.commons:commons-collections4:4.4' implementation 'org.apache.commons:commons-lang3:3.9' implementation 'net.openid:appauth:0.7.0' implementation 'com.google.android.material:material:1.0.0' // for tests androidTestImplementation 'androidx.test:runner:1.2.0' Loading
app/src/main/java/foundation/e/accountmanager/DavService.kt +8 −5 Original line number Diff line number Diff line Loading @@ -273,12 +273,16 @@ class DavService: android.app.Service() { .build().use { client -> val httpClient = client.okHttpClient val authState = service.authState var authState : String? = null service.authState?.let { authstate -> authState = AuthState.jsonDeserialize(authstate).accessToken } // refresh home set list (from principal) service.principal?.let { principalUrl -> Logger.log.fine("Querying principal $principalUrl for home sets") queryHomeSets(httpClient, principalUrl, AuthState.jsonDeserialize(authState).accessToken) queryHomeSets(httpClient, principalUrl, authState) } // now refresh homesets and their member collections Loading @@ -288,7 +292,7 @@ class DavService: android.app.Service() { Logger.log.fine("Listing home set ${homeSet.key}") try { DavResource(httpClient, homeSet.key, AuthState.jsonDeserialize(authState).accessToken).propfind(1, *DAV_COLLECTION_PROPERTIES) { response, relation -> DavResource(httpClient, homeSet.key, authState).propfind(1, *DAV_COLLECTION_PROPERTIES) { response, relation -> if (!response.isSuccess()) return@propfind Loading Loading @@ -322,7 +326,7 @@ class DavService: android.app.Service() { val (url, info) = itCollections.next() if (!info.confirmed) try { DavResource(httpClient, url, AuthState.jsonDeserialize(authState).accessToken).propfind(0, *DAV_COLLECTION_PROPERTIES) { response, _ -> DavResource(httpClient, url, authState).propfind(0, *DAV_COLLECTION_PROPERTIES) { response, _ -> if (!response.isSuccess()) return@propfind Loading @@ -345,7 +349,6 @@ class DavService: android.app.Service() { } } saveResults() } catch(e: InvalidAccountException) { Loading
app/src/main/java/foundation/e/accountmanager/model/Service.kt +1 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ data class Service( var accountName: String, var authState: String, var authState: String?, var accountType: String, var addressBookAccountType: String, Loading
app/src/main/java/foundation/e/accountmanager/ui/setup/AccountDetailsFragment.kt +7 −7 Original line number Diff line number Diff line Loading @@ -201,7 +201,7 @@ class AccountDetailsFragment: Fragment() { if (config.cardDAV != null) { // insert CardDAV service val id = insertService(db, name, credentials.authState!!.jsonSerializeString(), accountType, addressBookAccountType, Service.TYPE_CARDDAV, config.cardDAV) val id = insertService(db, name, credentials.authState?.jsonSerializeString(), accountType, addressBookAccountType, Service.TYPE_CARDDAV, config.cardDAV) // initial CardDAV account settings accountSettings.setGroupMethod(groupMethod) Loading @@ -217,7 +217,7 @@ class AccountDetailsFragment: Fragment() { if (config.calDAV != null) { // insert CalDAV service val id = insertService(db, name, credentials.authState!!.jsonSerializeString(), accountType, addressBookAccountType, Service.TYPE_CALDAV, config.calDAV) val id = insertService(db, name, credentials.authState?.jsonSerializeString(), accountType, addressBookAccountType, Service.TYPE_CALDAV, config.calDAV) // start CalDAV service detection (refresh collections) refreshIntent.putExtra(DavService.EXTRA_DAV_SERVICE_ID, id) Loading Loading @@ -247,7 +247,7 @@ class AccountDetailsFragment: Fragment() { return result } private fun insertService(db: AppDatabase, accountName: String, authState: String, accountType: String, addressBookAccountType: String, type: String, info: DavResourceFinder.Configuration.ServiceInfo): Long { private fun insertService(db: AppDatabase, accountName: String, authState: String?, accountType: String, addressBookAccountType: String, type: String, info: DavResourceFinder.Configuration.ServiceInfo): Long { // insert service val service = Service(0, accountName, authState, accountType, addressBookAccountType, type, info.principal) val serviceId = db.serviceDao().insertOrReplace(service) Loading
app/src/main/java/foundation/e/accountmanager/ui/setup/DavResourceFinder.kt +3 −3 Original line number Diff line number Diff line Loading @@ -173,7 +173,7 @@ class DavResourceFinder( private fun checkUserGivenURL(baseURL: HttpUrl, service: Service, config: Configuration.ServiceInfo) { log.info("Checking user-given URL: $baseURL") val davBase = DavResource(httpClient.okHttpClient, baseURL, loginModel.credentials!!.authState!!.accessToken, log) val davBase = DavResource(httpClient.okHttpClient, baseURL, loginModel.credentials?.authState?.accessToken, log) try { when (service) { Service.CARDDAV -> { Loading Loading @@ -296,7 +296,7 @@ class DavResourceFinder( fun providesService(url: HttpUrl, service: Service): Boolean { var provided = false try { DavResource(httpClient.okHttpClient, url, loginModel.credentials!!.authState!!.accessToken, log).options { capabilities, _ -> DavResource(httpClient.okHttpClient, url, loginModel.credentials?.authState?.accessToken, log).options { capabilities, _ -> if ((service == Service.CARDDAV && capabilities.contains("addressbook")) || (service == Service.CALDAV && capabilities.contains("calendar-access"))) provided = true Loading Loading @@ -382,7 +382,7 @@ class DavResourceFinder( @Throws(IOException::class, HttpException::class, DavException::class) fun getCurrentUserPrincipal(url: HttpUrl, service: Service?): HttpUrl? { var principal: HttpUrl? = null DavResource(httpClient.okHttpClient, url, loginModel.credentials!!.authState!!.accessToken, log).propfind(0, CurrentUserPrincipal.NAME) { response, _ -> DavResource(httpClient.okHttpClient, url, loginModel.credentials?.authState?.accessToken, log).propfind(0, CurrentUserPrincipal.NAME) { response, _ -> response[CurrentUserPrincipal::class.java]?.href?.let { href -> response.requestedUrl.resolve(href)?.let { log.info("Found current-user-principal: $it") Loading