Skip to content

Commit

Permalink
Update dbus-java to 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Xerus committed Mar 22, 2019
1 parent 1736c84 commit 649b669
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ allprojects {
}

dependencies {
compile("com.github.hypfvieh", "dbus-java", "2.7.5")
compile("com.github.hypfvieh", "dbus-java", "3.0.2")
compile(kotlin("stdlib"))
}
8 changes: 4 additions & 4 deletions extensions/src/xerus/mpris/AbstractMPRISPlayer.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package xerus.mpris

import org.freedesktop.DBus
import org.freedesktop.dbus.DBusConnection
import org.freedesktop.dbus.Variant
import org.freedesktop.dbus.connections.impl.DBusConnection
import org.freedesktop.dbus.types.Variant
import org.mpris.MediaPlayer2.*

/** Provides a typesafe foundation for implementing an MPRISPlayer.
Expand All @@ -14,7 +14,7 @@ import org.mpris.MediaPlayer2.*
* */
abstract class AbstractMPRISPlayer: MediaPlayerX, PlayerX, DefaultDBus {

val connection: DBusConnection = DBusConnection.getConnection(DBusConnection.SESSION)
val connection: DBusConnection = DBusConnection.getConnection(DBusConnection.DBusBusType.SESSION)
val properties = HashMap<String, MutableMap<String, Variant<*>>>()
internal val propertyListeners = HashMap<String, (Any) -> Unit>()

Expand All @@ -35,7 +35,7 @@ abstract class AbstractMPRISPlayer: MediaPlayerX, PlayerX, DefaultDBus {

/** sends a [DBus.Properties.PropertiesChanged] signal via [connection] */
override fun propertyChanged(interface_name: String, property_name: String) =
super.propertyChanged(interface_name, property_name).also { connection.sendSignal(it) }
super.propertyChanged(interface_name, property_name).also { connection.sendMessage(it) }

override val hasTrackList by DBusConstant(this is TrackList)

Expand Down
4 changes: 2 additions & 2 deletions extensions/src/xerus/mpris/DBusPropertyDelegate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package xerus.mpris

import javafx.beans.value.ObservableValue
import org.freedesktop.dbus.DBusInterfaceName
import org.freedesktop.dbus.annotations.DBusInterfaceName
import org.slf4j.LoggerFactory
import kotlin.properties.ReadOnlyProperty
import kotlin.properties.ReadWriteProperty
Expand Down Expand Up @@ -99,7 +99,7 @@ private class Property<T: Any>(private val interfaceName: String, private val na
println("setting $name in $interfaceName to $value")
try {
if(thisRef.properties.getValue(interfaceName).put(name, value.variant())?.value != value)
thisRef.connection.sendSignal(thisRef.propertyChanged(interfaceName, name))
thisRef.connection.sendMessage(thisRef.propertyChanged(interfaceName, name))
} catch(t: Throwable) {
t.printStackTrace()
}
Expand Down
5 changes: 3 additions & 2 deletions extensions/src/xerus/mpris/DefaultDBus.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package xerus.mpris

import org.freedesktop.DBus.Properties
import org.freedesktop.dbus.Variant
import org.freedesktop.dbus.interfaces.Properties
import org.freedesktop.dbus.types.DBusMapType
import org.freedesktop.dbus.types.Variant
import java.security.InvalidParameterException
import java.util.*
import kotlin.reflect.KClass


fun Any.variant(): Variant<*> {
if(this is Variant<*>)
return this
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/xerus/mpris/PropertyMap.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package xerus.mpris

import org.freedesktop.dbus.Variant
import org.freedesktop.dbus.types.Variant
import java.util.*

class PropertyMap private constructor(private val map: MutableMap<String, Variant<*>>): MutableMap<String, Variant<*>> by map {
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/xerus/mpris/Track.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package xerus.mpris

import org.freedesktop.dbus.Variant
import org.freedesktop.dbus.types.Variant

/** Represents a Track with Metadata.
* This is not an actual DBus-object, but rather a convenience wrapper around the metadata. */
Expand Down
9 changes: 4 additions & 5 deletions extensions/test/xerus/mpris/MPRISPlayer.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package xerus.mpris

import org.freedesktop.DBus
import org.freedesktop.DBus.Properties.PropertiesChanged
import org.freedesktop.dbus.Variant
import org.freedesktop.dbus.interfaces.Properties
import org.freedesktop.dbus.types.DBusMapType
import org.freedesktop.dbus.types.Variant
import org.mpris.MediaPlayer2.LoopStatus
import org.mpris.MediaPlayer2.MediaPlayer2
import org.mpris.MediaPlayer2.PlaybackStatus
Expand All @@ -19,7 +18,7 @@ fun main() {
MPRISPlayer().exportAs(playerName)
}

class MPRISPlayer: AbstractMPRISPlayer(), MediaPlayer2, Player, DBus.Properties {
class MPRISPlayer: AbstractMPRISPlayer(), MediaPlayer2, Player, Properties {

override var playbackStatus by DBusProperty(PlaybackStatus.Stopped)
override var loopStatus: LoopStatus = LoopStatus.None
Expand Down Expand Up @@ -116,7 +115,7 @@ class MPRISPlayer: AbstractMPRISPlayer(), MediaPlayer2, Player, DBus.Properties
val new = Variant(value)
properties[interface_name]!![name] = new
try {
connection.sendSignal(PropertiesChanged("/org/mpris/MediaPlayer2", interface_name, Collections.singletonMap(name, new) as Map<String, Variant<*>>, Collections.emptyList()))
connection.sendMessage(Properties.PropertiesChanged("/org/mpris/MediaPlayer2", interface_name, Collections.singletonMap(name, new) as Map<String, Variant<*>>, Collections.emptyList()))
} catch(e: Throwable) {
e.printStackTrace()
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/org/mpris/MediaPlayer2/DBusPlayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

package org.mpris.MediaPlayer2

import org.freedesktop.dbus.DBusInterface
import org.freedesktop.dbus.DBusInterfaceName
import org.freedesktop.dbus.DBusSignal
import org.freedesktop.dbus.annotations.DBusInterfaceName
import org.freedesktop.dbus.interfaces.DBusInterface
import org.freedesktop.dbus.messages.DBusSignal

/** [https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html]
*
Expand Down
4 changes: 2 additions & 2 deletions src/main/org/mpris/MediaPlayer2/MediaPlayer2.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.mpris.MediaPlayer2

import org.freedesktop.dbus.DBusInterface
import org.freedesktop.dbus.DBusInterfaceName
import org.freedesktop.dbus.annotations.DBusInterfaceName
import org.freedesktop.dbus.interfaces.DBusInterface

/** [https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html]
*
Expand Down
8 changes: 4 additions & 4 deletions src/main/org/mpris/MediaPlayer2/Playlists.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

package org.mpris.MediaPlayer2

import org.freedesktop.dbus.DBusInterface
import org.freedesktop.dbus.DBusInterfaceName
import org.freedesktop.dbus.DBusSignal
import org.freedesktop.dbus.Position
import org.freedesktop.dbus.Struct
import org.freedesktop.dbus.annotations.DBusInterfaceName
import org.freedesktop.dbus.annotations.Position
import org.freedesktop.dbus.interfaces.DBusInterface
import org.freedesktop.dbus.messages.DBusSignal

typealias PlaylistId = DBusPath

Expand Down
8 changes: 4 additions & 4 deletions src/main/org/mpris/MediaPlayer2/TrackList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

package org.mpris.MediaPlayer2

import org.freedesktop.dbus.DBusInterface
import org.freedesktop.dbus.DBusInterfaceName
import org.freedesktop.dbus.DBusSignal
import org.freedesktop.dbus.Variant
import org.freedesktop.dbus.annotations.DBusInterfaceName
import org.freedesktop.dbus.interfaces.DBusInterface
import org.freedesktop.dbus.messages.DBusSignal
import org.freedesktop.dbus.types.Variant

typealias TrackId = String

Expand Down

0 comments on commit 649b669

Please sign in to comment.