class Ping
Public Instance Methods
start(name, oldValue, newValue)
click to toggle source
# File examples/qdbus/complexpingpong/complexping.rb, line 32 def start(name, oldValue, newValue) if name != SERVICE_NAME || newValue.empty? return end # find our remote iface = Qt::DBusInterface.new(SERVICE_NAME, "/", "com.trolltech.QtDBus.ComplexPong.Pong", Qt::DBusConnection.sessionBus, self) if !iface.valid? $stderr.puts("%s" % Qt::DBusConnection.sessionBus.lastError.message) Qt::CoreApplication.instance.quit end connect(iface, SIGNAL(:aboutToQuit), Qt::CoreApplication.instance(), SLOT(:quit)) while true print("Ask your question: ") line = gets.strip if line.empty? iface.call("quit") return elsif line == "value" reply = iface.value if !reply.nil? puts("value = %s" % reply) end elsif line =~ /^value=/ iface.setValue Qt::Variant.new(line[6, line.length]) else reply = Qt::DBusReply.new(iface.call("query", Qt::Variant.new(line))) if reply.valid? puts("Reply was: %s" % reply.value.value) end end if iface.lastError.valid? $stderr.puts("Call failed: %s" % iface.lastError.message) end end end