[Kde-bindings] KDE/kdebindings/qtruby
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Tue Oct 3 12:31:24 UTC 2006
SVN commit 591910 by rdale:
* Added a ruby version of the Qt::DBusReply class
* Converted the qdbus/listnames example to Ruby
CCMAIL: kde-bindings at kde.org
M +4 -0 ChangeLog
A rubylib/examples/qdbus (directory)
A rubylib/examples/qdbus/listnames (directory)
A rubylib/examples/qdbus/listnames/listnames.rb
M +43 -6 rubylib/qtruby/lib/Qt/qtruby4.rb
--- trunk/KDE/kdebindings/qtruby/ChangeLog #591909:591910
@@ -9,6 +9,10 @@
* Fixed incorrect Qt::Variant.toUInt() method name
+ * Added a ruby version of the Qt::DBusReply class
+
+ * Converted the qdbus/listnames example to Ruby
+
2006-10-02 Richard Dale <rdale at foton.es>
* qVariantFromValue() wasn't working with non-Qt classes as arguments,
--- trunk/KDE/kdebindings/qtruby/rubylib/qtruby/lib/Qt/qtruby4.rb #591909:591910
@@ -400,15 +400,15 @@
class DBusConnectionInterface < Qt::Base
def serviceOwner(name)
- return internalConstCall(Qt::DBus::AutoDetect, "GetNameOwner", [Qt::Variant.new(name)]).value
+ return Qt::DBusReply.new(internalConstCall(Qt::DBus::AutoDetect, "GetNameOwner", [Qt::Variant.new(name)]))
end
def registeredServiceNames
- return internalConstCall(Qt::DBus::AutoDetect, "ListNames").value
+ return Qt::DBusReply.new(internalConstCall(Qt::DBus::AutoDetect, "ListNames"))
end
def isServiceRegistered(serviceName)
- return internalConstCall(Qt::DBus::AutoDetect, "NameHasOwner", [Qt::Variant.new(serviceName)]).value
+ return Qt::DBusReply.new(internalConstCall(Qt::DBus::AutoDetect, "NameHasOwner", [Qt::Variant.new(serviceName)]))
end
def serviceRegistered?(serviceName)
@@ -416,11 +416,11 @@
end
def servicePid(serviceName)
- return internalConstCall(Qt::DBus::AutoDetect, "GetConnectionUnixProcessID", [Qt::Variant.new(serviceName)]).value
+ return Qt::DBusReply.new(internalConstCall(Qt::DBus::AutoDetect, "GetConnectionUnixProcessID", [Qt::Variant.new(serviceName)]))
end
def serviceUid(serviceName)
- return internalConstCall(Qt::DBus::AutoDetect, "GetConnectionUnixUser", [Qt::Variant.new(serviceName)]).value
+ return Qt::DBusReply.new(internalConstCall(Qt::DBus::AutoDetect, "GetConnectionUnixUser", [Qt::Variant.new(serviceName)]))
end
def startService(name)
@@ -440,7 +440,7 @@
else
# create an Array 'dbusArgs' of Qt::Variants from '*args'
qdbusArgs = args.collect {|arg| qVariantFromValue(arg)}
- return qdbusMessage = call(id.to_s, *dbusArgs).value
+ return call(id.to_s, *dbusArgs).value
end
end
end
@@ -461,6 +461,43 @@
end
end
+ class DBusReply
+ def initialize(reply)
+ @error = Qt::DBusError.new(reply)
+
+ if @error.valid?
+ @data = Qt::Variant.new
+ return
+ end
+
+ if reply.arguments.length >= 1
+ @data = reply.arguments[0]
+ return
+ end
+
+ # error
+ @error = Qt::DBusError.new( Qt::DBusError::InvalidSignature,
+ "Unexpected reply signature" )
+ @data = Qt::Variant.new # clear it
+ end
+
+ def isValid
+ return !@error.isValid
+ end
+
+ def valid?
+ return !@error.isValid
+ end
+
+ def value
+ return @data.to_ruby
+ end
+
+ def error
+ return @error
+ end
+ end
+
class Dialog < Qt::Base
def exec(*args)
method_missing(:exec, *args)
More information about the Kde-bindings
mailing list