[F] Fix VTODO files in Folder
[+] Add Globals.kt
This commit is contained in:
parent
5e3442810b
commit
a36670d585
4 changed files with 56 additions and 48 deletions
|
@ -5,6 +5,7 @@
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleHome" value="/usr/share/java/gradle" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
|
|
||||||
rootProject.name = "mail-calendar-reminder-kotlin"
|
rootProject.name = "mail-calendar-reminder-kotlin"
|
||||||
|
|
||||||
|
|
1
src/main/kotlin/Globals.kt
Normal file
1
src/main/kotlin/Globals.kt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
public const val VERSION = 1.0;
|
|
@ -55,6 +55,7 @@ fun main(args: Array<String>) {
|
||||||
val path = Paths.get("")
|
val path = Paths.get("")
|
||||||
val directoryName = path.toAbsolutePath().toString()
|
val directoryName = path.toAbsolutePath().toString()
|
||||||
logger.debug("Current Working Directory is = $directoryName")
|
logger.debug("Current Working Directory is = $directoryName")
|
||||||
|
|
||||||
if (args.size <= 4) {
|
if (args.size <= 4) {
|
||||||
logger.error("Es fehlen noch einige Parameter!!!")
|
logger.error("Es fehlen noch einige Parameter!!!")
|
||||||
logger.error("ics-dir, from, to, password, host")
|
logger.error("ics-dir, from, to, password, host")
|
||||||
|
@ -88,61 +89,68 @@ fun getNotifications(file: String) {
|
||||||
FileInputStream(file).use { fin ->
|
FileInputStream(file).use { fin ->
|
||||||
val builder = CalendarBuilder()
|
val builder = CalendarBuilder()
|
||||||
val calendar: net.fortuna.ical4j.model.Calendar = builder.build(fin)
|
val calendar: net.fortuna.ical4j.model.Calendar = builder.build(fin)
|
||||||
|
var isValidVEVENT = false
|
||||||
|
|
||||||
for (o: Component in calendar.components) {
|
for (o: Component in calendar.components) {
|
||||||
logger.debug("Component: " + o.name)
|
logger.debug("Component: " + o.name)
|
||||||
for (o1: Property in o.properties) {
|
for (o1: Property in o.properties) {
|
||||||
logger.debug(o1.name + ": " + o1.value)
|
logger.debug(o1.name + ": " + o1.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (o.name.equals("VEVENT"))
|
||||||
|
isValidVEVENT = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://www.cheerfulprogramming.com/blog/2021/03/09/intro-to-ical4j
|
if (isValidVEVENT) {
|
||||||
val event: VEvent = calendar.getComponent(Component.VEVENT)
|
// http://www.cheerfulprogramming.com/blog/2021/03/09/intro-to-ical4j
|
||||||
|
val event: VEvent = calendar.getComponent(Component.VEVENT)
|
||||||
|
|
||||||
// https://www.ical4j.org/examples/recur/
|
// https://www.ical4j.org/examples/recur/
|
||||||
// https://stackoverflow.com/questions/1005523/how-to-add-one-day-to-a-date
|
// https://stackoverflow.com/questions/1005523/how-to-add-one-day-to-a-date
|
||||||
// Create the date range which is desired.
|
// Create the date range which is desired.
|
||||||
val dt: Date = Date()
|
val dt: Date = Date()
|
||||||
val arrival: Calendar = Calendar.getInstance()
|
val arrival: Calendar = Calendar.getInstance()
|
||||||
arrival.time = dt
|
arrival.time = dt
|
||||||
arrival.set(Calendar.SECOND, 1)
|
arrival.set(Calendar.SECOND, 1)
|
||||||
arrival.set(Calendar.MINUTE, 0)
|
arrival.set(Calendar.MINUTE, 0)
|
||||||
arrival.set(Calendar.HOUR, 0)
|
arrival.set(Calendar.HOUR, 0)
|
||||||
val departure: Calendar = Calendar.getInstance()
|
val departure: Calendar = Calendar.getInstance()
|
||||||
departure.time = dt
|
departure.time = dt
|
||||||
departure.set(Calendar.SECOND, 59)
|
departure.set(Calendar.SECOND, 59)
|
||||||
departure.set(Calendar.MINUTE, 59)
|
departure.set(Calendar.MINUTE, 59)
|
||||||
departure.set(Calendar.HOUR, 23)
|
departure.set(Calendar.HOUR, 23)
|
||||||
// departure.add(Calendar.DATE, 1);
|
// departure.add(Calendar.DATE, 1);
|
||||||
val fromTime: DateTime = DateTime(arrival.time)
|
val fromTime: DateTime = DateTime(arrival.time)
|
||||||
val toTime: DateTime = DateTime(departure.time)
|
val toTime: DateTime = DateTime(departure.time)
|
||||||
val period: Period = Period(fromTime, toTime)
|
val period: Period = Period(fromTime, toTime)
|
||||||
val list: PeriodList = event.calculateRecurrenceSet(period)
|
val list: PeriodList = event.calculateRecurrenceSet(period)
|
||||||
for (po: Period in list) {
|
for (po: Period in list) {
|
||||||
val component: Component = po.component
|
val component: Component = po.component
|
||||||
val summary: Summary =
|
val summary: Summary =
|
||||||
component.getProperty(Property.SUMMARY)
|
component.getProperty(Property.SUMMARY)
|
||||||
val dtStart: DtStart = component.getProperty(Property.DTSTART)
|
val dtStart: DtStart = component.getProperty(Property.DTSTART)
|
||||||
val dtEnd: DtEnd = component.getProperty(Property.DTEND)
|
val dtEnd: DtEnd = component.getProperty(Property.DTEND)
|
||||||
val location: Location? =
|
val location: Location? =
|
||||||
component.getProperty(Property.LOCATION)
|
component.getProperty(Property.LOCATION)
|
||||||
val description: Description? =
|
val description: Description? =
|
||||||
component.getProperty(Property.DESCRIPTION)
|
component.getProperty(Property.DESCRIPTION)
|
||||||
|
|
||||||
// Summary summary = po.getSummary();
|
// Summary summary = po.getSummary();
|
||||||
val messageSubject: String = ("Es existiert für heute ein neuer Kalendereintrag Namens: "
|
val messageSubject: String = ("Es existiert für heute ein neuer Kalendereintrag Namens: "
|
||||||
+ summary.value)
|
+ summary.value)
|
||||||
logger.info(messageSubject)
|
logger.info(messageSubject)
|
||||||
var messageText: String = ("Der Termin beginnt heute um: " + formatDateTime(dtStart.date)
|
var messageText: String = ("Der Termin beginnt heute um: " + formatDateTime(dtStart.date)
|
||||||
+ " und endet um: " + formatDateTime(dtEnd.date) + ".")
|
+ " und endet um: " + formatDateTime(dtEnd.date) + ".")
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
messageText += "\n\n Er findet in " + location.value + " statt."
|
messageText += "\n\n Er findet in " + location.value + " statt."
|
||||||
|
}
|
||||||
|
if (description != null) {
|
||||||
|
messageText += "\n\n Folgende Notiz existiert in diesen Eintrag: \n" + description.value
|
||||||
|
}
|
||||||
|
messageText += "\n\n This email is a service from mail-calendar-reminder Version $VERSION. \n Delivered by Simon Rieger"
|
||||||
|
logger.info(messageText)
|
||||||
|
sendMail(messageSubject, messageText)
|
||||||
}
|
}
|
||||||
if (description != null) {
|
|
||||||
messageText += "\n\n Folgende Notiz existiert in diesen Eintrag: \n" + description.value
|
|
||||||
}
|
|
||||||
messageText += "\n\n This email is a service from mail-calendar-reminder Version 0.1. \n Delivered by Simon Rieger"
|
|
||||||
logger.info(messageText)
|
|
||||||
sendMail(messageSubject, messageText)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
|
|
Loading…
Reference in a new issue