Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ import android.content.Entity
import android.provider.CalendarContract.Events
import android.provider.CalendarContract.ExtendedProperties
import at.bitfire.synctools.icalendar.AssociatedEvents
import at.bitfire.synctools.mapping.calendar.processor.AccessLevelProcessor
import at.bitfire.synctools.mapping.calendar.processor.AndroidEventFieldProcessor
import at.bitfire.synctools.mapping.calendar.processor.AttendeesProcessor
import at.bitfire.synctools.mapping.calendar.processor.AvailabilityProcessor
import at.bitfire.synctools.mapping.calendar.processor.CategoriesProcessor
import at.bitfire.synctools.mapping.calendar.processor.ColorProcessor
import at.bitfire.synctools.mapping.calendar.processor.DescriptionProcessor
import at.bitfire.synctools.mapping.calendar.processor.DurationProcessor
import at.bitfire.synctools.mapping.calendar.processor.EndTimeProcessor
import at.bitfire.synctools.mapping.calendar.processor.LocationProcessor
import at.bitfire.synctools.mapping.calendar.processor.OrganizerProcessor
import at.bitfire.synctools.mapping.calendar.processor.OriginalInstanceTimeProcessor
import at.bitfire.synctools.mapping.calendar.processor.RecurrenceFieldsProcessor
import at.bitfire.synctools.mapping.calendar.processor.RemindersProcessor
import at.bitfire.synctools.mapping.calendar.processor.SequenceProcessor
import at.bitfire.synctools.mapping.calendar.processor.StartTimeProcessor
import at.bitfire.synctools.mapping.calendar.processor.StatusProcessor
import at.bitfire.synctools.mapping.calendar.processor.TitleProcessor
import at.bitfire.synctools.mapping.calendar.processor.UidProcessor
import at.bitfire.synctools.mapping.calendar.processor.UnknownPropertiesProcessor
import at.bitfire.synctools.mapping.calendar.processor.UrlProcessor
import at.bitfire.synctools.mapping.calendar.handler.AccessLevelHandler
import at.bitfire.synctools.mapping.calendar.handler.AndroidEventFieldHandler
import at.bitfire.synctools.mapping.calendar.handler.AttendeesHandler
import at.bitfire.synctools.mapping.calendar.handler.AvailabilityHandler
import at.bitfire.synctools.mapping.calendar.handler.CategoriesHandler
import at.bitfire.synctools.mapping.calendar.handler.ColorHandler
import at.bitfire.synctools.mapping.calendar.handler.DescriptionHandler
import at.bitfire.synctools.mapping.calendar.handler.DurationHandler
import at.bitfire.synctools.mapping.calendar.handler.EndTimeHandler
import at.bitfire.synctools.mapping.calendar.handler.LocationHandler
import at.bitfire.synctools.mapping.calendar.handler.OrganizerHandler
import at.bitfire.synctools.mapping.calendar.handler.OriginalInstanceTimeHandler
import at.bitfire.synctools.mapping.calendar.handler.RecurrenceFieldsHandler
import at.bitfire.synctools.mapping.calendar.handler.RemindersHandler
import at.bitfire.synctools.mapping.calendar.handler.SequenceHandler
import at.bitfire.synctools.mapping.calendar.handler.StartTimeHandler
import at.bitfire.synctools.mapping.calendar.handler.StatusHandler
import at.bitfire.synctools.mapping.calendar.handler.TitleHandler
import at.bitfire.synctools.mapping.calendar.handler.UidHandler
import at.bitfire.synctools.mapping.calendar.handler.UnknownPropertiesHandler
import at.bitfire.synctools.mapping.calendar.handler.UrlHandler
import at.bitfire.synctools.storage.calendar.EventAndExceptions
import at.bitfire.synctools.storage.calendar.EventsContract
import net.fortuna.ical4j.model.DateList
Expand All @@ -51,38 +51,38 @@ import java.util.UUID
* @param accountName account name (used to generate reminder email address)
* @param prodIdGenerator generates the `PRODID` to use
*/
class AndroidEventProcessor(
class AndroidEventHandler(
accountName: String,
private val prodIdGenerator: ProdIdGenerator
) {

private val tzRegistry = TimeZoneRegistryFactory.getInstance().createRegistry()

private val fieldProcessors: Array<AndroidEventFieldProcessor> = arrayOf(
private val fieldHandlers: Array<AndroidEventFieldHandler> = arrayOf(
// event row fields
UidProcessor(),
OriginalInstanceTimeProcessor(tzRegistry),
TitleProcessor(),
LocationProcessor(),
StartTimeProcessor(tzRegistry),
EndTimeProcessor(tzRegistry),
DurationProcessor(tzRegistry),
RecurrenceFieldsProcessor(tzRegistry),
DescriptionProcessor(),
ColorProcessor(),
AccessLevelProcessor(),
AvailabilityProcessor(),
StatusProcessor(),
UidHandler(),
OriginalInstanceTimeHandler(tzRegistry),
TitleHandler(),
LocationHandler(),
StartTimeHandler(tzRegistry),
EndTimeHandler(tzRegistry),
DurationHandler(tzRegistry),
RecurrenceFieldsHandler(tzRegistry),
DescriptionHandler(),
ColorHandler(),
AccessLevelHandler(),
AvailabilityHandler(),
StatusHandler(),
// scheduling
SequenceProcessor(),
OrganizerProcessor(),
AttendeesProcessor(),
SequenceHandler(),
OrganizerHandler(),
AttendeesHandler(),
// extended properties
CategoriesProcessor(),
UnknownPropertiesProcessor(),
UrlProcessor(),
CategoriesHandler(),
UnknownPropertiesHandler(),
UrlHandler(),
// sub-components
RemindersProcessor(accountName)
RemindersHandler(accountName)
)


Expand All @@ -102,7 +102,7 @@ class AndroidEventProcessor(
/**
* Maps an Android event with its exceptions to VEVENTs.
*
* VEVENTs must have a valid `UID`, so this method (or better to say, the [UidProcessor] that it calls)
* VEVENTs must have a valid `UID`, so this method (or better to say, the [UidHandler] that it calls)
* generates an UID, if necessary. If an `UID` was generated, it is noted in the result.
*/
fun mapToVEvents(eventAndExceptions: EventAndExceptions): MappingResult {
Expand Down Expand Up @@ -190,8 +190,8 @@ class AndroidEventProcessor(
// initialization adds DTSTAMP
val vEvent = VEvent(/* initialise = */ true)

for (processor in fieldProcessors)
processor.process(from = entity, main = main, to = vEvent)
for (handler in fieldHandlers)
handler.process(from = entity, main = main, to = vEvent)
return vEvent
}

Expand Down Expand Up @@ -220,7 +220,7 @@ class AndroidEventProcessor(
it.values.getAsString(ExtendedProperties.NAME) == EventsContract.EXTNAME_GOOGLE_CALENDAR_UID
}?.values?.getAsString(ExtendedProperties.VALUE)
if (googleCalendarUid != null) {
// copy to UID_2445 so that it will be processed by UidProcessor and return
// copy to UID_2445 so that it will be processed by UidHandler and return
mainValues.put(Events.UID_2445, googleCalendarUid)
return googleCalendarUid
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class EndTimeBuilder: AndroidEntityBuilder {
* - DTEND is DATE, DTSTART is DATE-TIME → DTEND is amended to DATE-TIME with time and timezone from DTSTART
* - DTEND is DATE-TIME, DTSTART is DATE → DTEND is reduced to its date component
*
* @see at.bitfire.synctools.mapping.calendar.processor.RecurrenceFieldsProcessor.alignUntil
* @see at.bitfire.synctools.mapping.calendar.handler.RecurrenceFieldsHandler.alignUntil
*/
@VisibleForTesting
internal fun alignWithDtStart(dtEnd: DtEnd, dtStart: DtStart): DtEnd {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.Entity
import android.provider.CalendarContract.Events
Expand All @@ -14,7 +14,7 @@ import net.fortuna.ical4j.model.component.VEvent
import net.fortuna.ical4j.model.property.Clazz
import org.json.JSONException

class AccessLevelProcessor: AndroidEventFieldProcessor {
class AccessLevelHandler: AndroidEventFieldHandler {

override fun process(from: Entity, main: Entity, to: VEvent) {
val values = from.entityValues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.Entity
import at.bitfire.synctools.exception.InvalidLocalResourceException
import net.fortuna.ical4j.model.component.VEvent

interface AndroidEventFieldProcessor {
interface AndroidEventFieldHandler {

/**
* Takes specific data from an event (= event row plus data rows, taken from the content provider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import at.bitfire.synctools.util.AndroidTimeUtils
import net.fortuna.ical4j.model.Date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.ContentValues
import android.content.Entity
Expand All @@ -21,7 +21,7 @@ import java.net.URISyntaxException
import java.util.logging.Level
import java.util.logging.Logger

class AttendeesProcessor: AndroidEventFieldProcessor {
class AttendeesHandler: AndroidEventFieldHandler {

private val logger
get() = Logger.getLogger(javaClass.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.Entity
import android.provider.CalendarContract.Events
import net.fortuna.ical4j.model.component.VEvent
import net.fortuna.ical4j.model.property.Transp

class AvailabilityProcessor: AndroidEventFieldProcessor {
class AvailabilityHandler: AndroidEventFieldHandler {

override fun process(from: Entity, main: Entity, to: VEvent) {
val transp: Transp = when (from.entityValues.getAsInteger(Events.AVAILABILITY)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.Entity
import android.provider.CalendarContract.ExtendedProperties
Expand All @@ -13,7 +13,7 @@ import net.fortuna.ical4j.model.TextList
import net.fortuna.ical4j.model.component.VEvent
import net.fortuna.ical4j.model.property.Categories

class CategoriesProcessor: AndroidEventFieldProcessor {
class CategoriesHandler: AndroidEventFieldHandler {

override fun process(from: Entity, main: Entity, to: VEvent) {
val extended = from.subValues.filter { it.uri == ExtendedProperties.CONTENT_URI }.map { it.values }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.Entity
import android.provider.CalendarContract.Events
Expand All @@ -13,7 +13,7 @@ import net.fortuna.ical4j.model.component.VEvent
import net.fortuna.ical4j.model.property.Color
import java.util.logging.Logger

class ColorProcessor: AndroidEventFieldProcessor {
class ColorHandler: AndroidEventFieldHandler {

private val logger
get() = Logger.getLogger(javaClass.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.Entity
import android.provider.CalendarContract.Events
import at.bitfire.vcard4android.Utils.trimToNull
import net.fortuna.ical4j.model.component.VEvent
import net.fortuna.ical4j.model.property.Description

class DescriptionProcessor: AndroidEventFieldProcessor {
class DescriptionHandler: AndroidEventFieldHandler {

override fun process(from: Entity, main: Entity, to: VEvent) {
val description = from.entityValues.getAsString(Events.DESCRIPTION).trimToNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.Entity
import android.provider.CalendarContract.Events
Expand All @@ -21,9 +21,9 @@ import java.time.Instant
import java.time.Period
import java.time.ZoneOffset

class DurationProcessor(
class DurationHandler(
private val tzRegistry: TimeZoneRegistry
): AndroidEventFieldProcessor {
): AndroidEventFieldHandler {

override fun process(from: Entity, main: Entity, to: VEvent) {
val values = from.entityValues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.Entity
import android.provider.CalendarContract.Events
Expand All @@ -13,9 +13,9 @@ import net.fortuna.ical4j.model.component.VEvent
import net.fortuna.ical4j.model.property.DtEnd
import java.util.logging.Logger

class EndTimeProcessor(
class EndTimeHandler(
private val tzRegistry: TimeZoneRegistry
): AndroidEventFieldProcessor {
): AndroidEventFieldHandler {

private val logger
get() = Logger.getLogger(javaClass.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.Entity
import android.provider.CalendarContract.Events
import at.bitfire.vcard4android.Utils.trimToNull
import net.fortuna.ical4j.model.component.VEvent
import net.fortuna.ical4j.model.property.Location

class LocationProcessor: AndroidEventFieldProcessor {
class LocationHandler: AndroidEventFieldHandler {

override fun process(from: Entity, main: Entity, to: VEvent) {
val location = from.entityValues.getAsString(Events.EVENT_LOCATION).trimToNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.Entity
import android.provider.CalendarContract.Attendees
Expand All @@ -16,7 +16,7 @@ import java.net.URISyntaxException
import java.util.logging.Level
import java.util.logging.Logger

class OrganizerProcessor: AndroidEventFieldProcessor {
class OrganizerHandler: AndroidEventFieldHandler {

private val logger
get() = Logger.getLogger(javaClass.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.Entity
import android.provider.CalendarContract.Events
Expand All @@ -16,9 +16,9 @@ import net.fortuna.ical4j.model.component.VEvent
import net.fortuna.ical4j.model.property.RecurrenceId
import net.fortuna.ical4j.util.TimeZones

class OriginalInstanceTimeProcessor(
class OriginalInstanceTimeHandler(
private val tzRegistry: TimeZoneRegistry
): AndroidEventFieldProcessor {
): AndroidEventFieldHandler {

override fun process(from: Entity, main: Entity, to: VEvent) {
// only applicable to exceptions, not to main events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package at.bitfire.synctools.mapping.calendar.processor
package at.bitfire.synctools.mapping.calendar.handler

import android.content.Entity
import android.provider.CalendarContract.Events
Expand All @@ -28,9 +28,9 @@ import java.util.LinkedList
import java.util.logging.Level
import java.util.logging.Logger

class RecurrenceFieldsProcessor(
class RecurrenceFieldsHandler(
private val tzRegistry: TimeZoneRegistry
): AndroidEventFieldProcessor {
): AndroidEventFieldHandler {

private val logger
get() = Logger.getLogger(javaClass.name)
Expand Down
Loading