mirror of
https://github.com/irmen/prog8.git
synced 2024-06-17 04:29:44 +00:00
various cleanups, slight update to dbus
This commit is contained in:
parent
dfbef8495d
commit
03ac9b6956
|
@ -1,15 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="KotlinJavaRuntime (2)">
|
||||
<CLASSES>
|
||||
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-stdlib.jar!/" />
|
||||
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect.jar!/" />
|
||||
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-test.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-stdlib-sources.jar!/" />
|
||||
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect-sources.jar!/" />
|
||||
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-test-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
|
@ -1,15 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="KotlinJavaRuntime (3)">
|
||||
<CLASSES>
|
||||
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-stdlib.jar!/" />
|
||||
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect.jar!/" />
|
||||
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-test.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-stdlib-sources.jar!/" />
|
||||
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect-sources.jar!/" />
|
||||
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-test-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
|
@ -1,22 +1,22 @@
|
|||
<component name="libraryTable">
|
||||
<library name="github.hypfvieh.dbus.java" type="repository">
|
||||
<properties maven-id="com.github.hypfvieh:dbus-java:3.3.0" />
|
||||
<properties maven-id="com.github.hypfvieh:dbus-java:3.3.1" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/hypfvieh/dbus-java/3.3.0/dbus-java-3.3.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jnr-unixsocket/0.38.5/jnr-unixsocket-0.38.5.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jnr-ffi/2.2.1/jnr-ffi-2.2.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/hypfvieh/dbus-java/3.3.1/dbus-java-3.3.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jnr-unixsocket/0.38.6/jnr-unixsocket-0.38.6.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jnr-ffi/2.2.2/jnr-ffi-2.2.2.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jffi/1.3.1/jffi-1.3.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jffi/1.3.1/jffi-1.3.1-native.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/ow2/asm/asm/9.0/asm-9.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/ow2/asm/asm-commons/9.0/asm-commons-9.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/ow2/asm/asm-analysis/9.0/asm-analysis-9.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/ow2/asm/asm-tree/9.0/asm-tree-9.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/ow2/asm/asm-util/9.0/asm-util-9.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/ow2/asm/asm/9.1/asm-9.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/ow2/asm/asm-commons/9.1/asm-commons-9.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/ow2/asm/asm-analysis/9.1/asm-analysis-9.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/ow2/asm/asm-tree/9.1/asm-tree-9.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/ow2/asm/asm-util/9.1/asm-util-9.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jnr-a64asm/1.0.0/jnr-a64asm-1.0.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jnr-x86asm/1.0.2/jnr-x86asm-1.0.2.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jnr-constants/0.10.1/jnr-constants-0.10.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jnr-enxio/0.32.3/jnr-enxio-0.32.3.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jnr-posix/3.1.4/jnr-posix-3.1.4.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jnr-enxio/0.32.4/jnr-enxio-0.32.4.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/github/jnr/jnr-posix/3.1.5/jnr-posix-3.1.5.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</content>
|
||||
<orderEntry type="jdk" jdkName="openjdk-11" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime (2)" level="project" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||
<orderEntry type="module" module-name="compilerInterfaces" />
|
||||
<orderEntry type="module" module-name="compilerAst" />
|
||||
<orderEntry type="library" scope="TEST" name="hamcrest" level="project" />
|
||||
|
|
|
@ -11,10 +11,6 @@ java {
|
|||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://kotlin.bintray.com/kotlinx" }
|
||||
}
|
||||
|
||||
def prog8version = rootProject.file('compiler/res/version.txt').text.trim()
|
||||
|
||||
dependencies {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</content>
|
||||
<orderEntry type="jdk" jdkName="openjdk-11" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime (3)" level="project" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||
<orderEntry type="module" module-name="compilerAst" />
|
||||
<orderEntry type="library" scope="TEST" name="hamcrest" level="project" />
|
||||
<orderEntry type="library" name="junit.jupiter" level="project" />
|
||||
|
|
|
@ -12,15 +12,11 @@ java {
|
|||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://kotlin.bintray.com/kotlinx" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
// implementation "org.jetbrains.kotlin:kotlin-reflect"
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-cli:0.3.3'
|
||||
implementation "com.github.hypfvieh:dbus-java:3.3.0"
|
||||
implementation "com.github.hypfvieh:dbus-java:3.3.1"
|
||||
implementation "org.slf4j:slf4j-simple:1.7.30"
|
||||
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test-junit5"
|
||||
|
@ -53,7 +49,7 @@ sourceSets {
|
|||
startScripts.enabled = true
|
||||
|
||||
application {
|
||||
mainClass = 'prog8.dbus.TestdbusKt'
|
||||
mainClass = 'prog8.dbus.DbusserverKt'
|
||||
applicationName = 'prog8compilerservicedbus'
|
||||
}
|
||||
|
||||
|
|
|
@ -11,5 +11,6 @@
|
|||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||
<orderEntry type="library" name="jetbrains.kotlinx.cli.jvm" level="project" />
|
||||
<orderEntry type="library" name="github.hypfvieh.dbus.java" level="project" />
|
||||
<orderEntry type="library" name="slf4j.simple" level="project" />
|
||||
</component>
|
||||
</module>
|
|
@ -1,15 +1,21 @@
|
|||
package prog8.dbus
|
||||
|
||||
import org.freedesktop.dbus.annotations.IntrospectionDescription
|
||||
import org.freedesktop.dbus.interfaces.DBusInterface
|
||||
|
||||
|
||||
const val serviceObjectPath = "/razorvine/TestService"
|
||||
|
||||
|
||||
interface IrmenDbusTest: DBusInterface
|
||||
{
|
||||
@IntrospectionDescription("return some sort of status")
|
||||
fun Status(address: String): Map<Int, String>
|
||||
}
|
||||
|
||||
|
||||
internal class TestService: IrmenDbusTest {
|
||||
|
||||
override fun Status(address: String): Map<Int, String> {
|
||||
return mapOf(
|
||||
5 to "hello",
|
||||
|
@ -18,5 +24,5 @@ internal class TestService: IrmenDbusTest {
|
|||
}
|
||||
|
||||
override fun isRemote() = true
|
||||
override fun getObjectPath() = "/razorvine/TestService"
|
||||
override fun getObjectPath() = serviceObjectPath
|
||||
}
|
||||
|
|
|
@ -2,16 +2,56 @@ package prog8.dbus
|
|||
|
||||
|
||||
import org.freedesktop.dbus.connections.impl.DBusConnection
|
||||
import org.freedesktop.dbus.exceptions.DBusExecutionException
|
||||
import org.freedesktop.dbus.interfaces.DBusInterface
|
||||
|
||||
/*
|
||||
|
||||
Inspect the dbus services interactively via the qdbusviewer tool.
|
||||
|
||||
|
||||
Command line access is also possible with:
|
||||
|
||||
$ dbus-send --session --dest=local.net.razorvine.prog8.dbus --type=method_call --print-reply /razorvine/TestService prog8.dbus.IrmenDbusTest.Status string:"hello world"
|
||||
|
||||
$ qdbus --literal local.net.razorvine.prog8.dbus /razorvine/TestService Status string:"hello world"
|
||||
|
||||
$ gdbus call --session -d local.net.razorvine.prog8.dbus -o /razorvine/TestService --method prog8.dbus.IrmenDbusTest.Status string:"hello world"
|
||||
|
||||
Or with the dasbus python library:
|
||||
|
||||
from dasbus.connection import SessionMessageBus
|
||||
from dasbus.identifier import DBusServiceIdentifier
|
||||
|
||||
PROG8_SERVICE = DBusServiceIdentifier(
|
||||
namespace=("local", "net", "razorvine", "prog8", "dbus"),
|
||||
message_bus=SessionMessageBus()
|
||||
)
|
||||
|
||||
proxy = PROG8_SERVICE.get_proxy("/razorvine/TestService")
|
||||
print(proxy.Status("hello world"))
|
||||
|
||||
|
||||
*/
|
||||
|
||||
inline fun <reified I: DBusInterface> DBusConnection.getRemote(busname: String, objectpath: String): I =
|
||||
this.getRemoteObject(busname, objectpath, I::class.java)
|
||||
|
||||
inline fun <reified I: DBusInterface> DBusConnection.getPeerRemote(busname: String, objectpath: String): I =
|
||||
this.getPeerRemoteObject(busname, objectpath, I::class.java)
|
||||
|
||||
|
||||
fun main() {
|
||||
DBusConnection.getConnection(DBusConnection.DBusBusType.SESSION).use {
|
||||
println(it.names.toList())
|
||||
println(it.uniqueName)
|
||||
println(it.address)
|
||||
println(it.machineId)
|
||||
val obj = it.getRemoteObject("local.net.razorvine.dbus.test", "/razorvine/TestService", IrmenDbusTest::class.java)
|
||||
println(obj.Status("irmen"))
|
||||
|
||||
try {
|
||||
|
||||
val obj = it.getRemote<IrmenDbusTest>("local.net.razorvine.prog8.dbus", serviceObjectPath)
|
||||
println(obj.Status("irmen"))
|
||||
|
||||
} catch (dx: DBusExecutionException) {
|
||||
println("DBUS ERROR! $dx")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
24
dbusCompilerService/src/prog8/dbus/dbusserver.kt
Normal file
24
dbusCompilerService/src/prog8/dbus/dbusserver.kt
Normal file
|
@ -0,0 +1,24 @@
|
|||
package prog8.dbus
|
||||
|
||||
import org.freedesktop.dbus.connections.impl.DBusConnection
|
||||
|
||||
|
||||
fun main() {
|
||||
val busname = "local.net.razorvine.prog8.dbus"
|
||||
|
||||
DBusConnection.getConnection(DBusConnection.DBusBusType.SESSION).use {
|
||||
it.requestBusName(busname)
|
||||
println("connection names : ${it.names.toList()}")
|
||||
println("connection unique name : ${it.uniqueName}")
|
||||
println("connection address : ${it.address}")
|
||||
println("connection machine id : ${it.machineId}")
|
||||
println("bus name for clients : $busname")
|
||||
println("object path for clients : $serviceObjectPath")
|
||||
|
||||
val service = TestService()
|
||||
it.exportObject(service.objectPath, service)
|
||||
|
||||
Thread.sleep(100000)
|
||||
it.releaseBusName(busname)
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package prog8.dbus
|
||||
|
||||
import org.freedesktop.dbus.connections.impl.DBusConnection
|
||||
|
||||
|
||||
fun main() {
|
||||
DBusConnection.getConnection(DBusConnection.DBusBusType.SESSION).use {
|
||||
it.requestBusName("local.net.razorvine.dbus.test")
|
||||
println(it.names.toList())
|
||||
println(it.uniqueName)
|
||||
println(it.address)
|
||||
println(it.machineId)
|
||||
val service = TestService()
|
||||
it.exportObject(service.objectPath, service)
|
||||
|
||||
Thread.sleep(100000)
|
||||
}
|
||||
}
|
|
@ -12,10 +12,6 @@ java {
|
|||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://kotlin.bintray.com/kotlinx" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':compilerInterfaces')
|
||||
implementation project(':compiler')
|
||||
|
|
Loading…
Reference in New Issue
Block a user