import kotlinx.coroutines.IO
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
+import java.io.IOException
-class App : Application {
+object App : Application {
var window: MainWindow? = null
+ var settings = Settings()
init {
initToolbar()
}
override fun startup() {
+ try {
+ settings.load()
+ } catch (e: IOException) {
+ e.printStackTrace() // TODO: messagebox
+ }
+
window = MainWindow()
window?.show()
- backgroundSync(10 * 1000L) // TODO: config
+ backgroundSync(settings.autoRefreshStartDelay * 1000L)
}
override fun shutdown() {
while(true) {
println("Background sync")
try {
- val pending = Database.getPendingFeeds(1 * 60) // TODO: config
+ val pending = Database.getPendingFeeds(settings.defaultRefreshInterval)
if(!pending.isEmpty()) {
SyncJob { pending }.syncBlocking()
GlobalScope.launch(ToolkitDispatcher) {
println("Background sync done")
// get time until the next feed is pending, but wait at least the minimum delay time
- var delayTimeMS = 60 * 1000L // TODO: config
+ var delayTimeMS = settings.minRefreshWaitTime * 1000L
try {
- val seconds = Database.getUpdateWaitTime(1 * 60) // TODO: config
+ val seconds = Database.getUpdateWaitTime(settings.defaultRefreshInterval)
if(seconds > 0) {
println("wait for $seconds seconds until next sync")
delayTimeMS = seconds * 1000L
fun main() {
Toolkit.init("rssreader")
- Toolkit.runApplication(App())
+ Toolkit.runApplication(App)
}
import java.time.ZoneId
import java.time.format.DateTimeFormatter
-class MainWindow {
+class MainWindow() {
val window : Toplevel
val sourceList = FeedSourceList()
val feedList = FeedList()
// TODO: date format config
- val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault())
+ val formatter = DateTimeFormatter.ofPattern(App.settings.dateFormat).withZone(ZoneId.systemDefault())
var newFeedPrevGroup = 0
--- /dev/null
+package de.unixwork.rssreader
+
+import de.unixwork.ui.Toolkit
+import java.io.File
+import java.util.Properties
+
+class Settings {
+ val properties = Properties()
+
+ val dateFormat = "yyyy-MM-dd HH:mm:ss"
+ val autoRefreshStartDelay = 10
+ val defaultRefreshInterval = 3600
+ val minRefreshWaitTime = 60
+
+ fun load() {
+ val filePath = Toolkit.getConfigFilePath("rssreader.properties")
+ val file = File(filePath)
+ if(file.exists()) {
+ file.inputStream().use {
+ properties.load(it)
+ }
+ } else {
+ println("create new file: $filePath")
+ file.createNewFile()
+ }
+ }
+}
\ No newline at end of file
MemorySegment ui_malloc_addr = lib.find("ui_malloc").orElseThrow();
MemorySegment ui_free_addr = lib.find("ui_free").orElseThrow();
- MemorySegment getappdir_addr = lib.find("getappdir").orElseThrow();
- MemorySegment configfile_addr = lib.find("configfile").orElseThrow();
+ MemorySegment getappdir_addr = lib.find("ui_getappdir").orElseThrow();
+ MemorySegment configfile_addr = lib.find("ui_configfile").orElseThrow();
MemorySegment malloc_addr = lib.find("malloc").orElseThrow();
MemorySegment free_addr = lib.find("free").orElseThrow();