I've been messing with with idea of dynamically adding DCOP slots to a running DCOP server program. I've got a little server with a slot called 'eval()' which takes a string of ruby code and evaluates it as a sort of 'compile command'. So you send the new code for a dcop slot to the server, it evaluates it, and you can then invoke the new slot.
Here is the code:
require 'Korundum'
include KDE
class DynamicDCOP < DCOPObject
k_dcop 'void eval(QString)'
def initialize
super "DynamicDCOPServer"
end
def eval(string)
DynamicDCOP.module_eval(string)
KDE.createDCOPObject(self)
end
end
about = AboutData.new("dynamicDCOP", "Dynamic DCOP", "0.1" )
CmdLineArgs.init(ARGV, about)
a = Application.new
dcop = DynamicDCOP.new
a.execThen use the kdcop app to send this string to the eval slot:
k_dcop 'QString hello()' ; def hello() 'hello world' end
Refresh the kdcop view, and you will see the new slot 'hello()', which will reply 'hello world' when called.
You wouldn't normally want to actually send code to a running DCOP server like this, but what it does mean is that SOAP services could be discovered on the fly, and the code for suitable dcop slots could be generated to invoke the SOAP service as a bridge.

dynamic programming
Dynamic programming can be scary. Like have you ever tried reading the code for the RSS lib distributed with ruby? Yikes!
In this instance it makes a lot of sense though... dynamic since the problem being solved is dynamic.
very cool
This is some of the stuff we talked about at FOSDEM, right? Exceedingly cool to see that you managed to pull it off. I'm very much looking forward to having some more time in a few weeks so I can (among other things) take a closer look. This is the kind of thing that can make KDE 4 really fly, in my opinion. Great stuff.
FOSDEM stuff
This is some of the stuff we talked about at FOSDEM, right?
Yes, indeed you're absolutely right - this is a result of those talks. I thought a DCOP/SOAP Bridge sounded a really good idea, and that ruby looked a lot simpler than gsoap C++ code generation that you were trying. On the other hand, I still need to actually call a SOAP service from ruby yet, but I'm taking baby steps towards that goal, like the dynamic dcop server code above, but it's looking good so far..
Is the webservices stuff in r
Is the webservices stuff in rails useful for this? IIRC is a stand alone module.
Re: The webservices stuff in ruby
There is a soap and wsdl library in ruby itself, I think rails uses that. At the moment I'm experimenting with extracting the parsed WSDL data to get methods that can be converted to DCOP slots. For instance, this will retrieve details about the Google search service:
require 'soap/wsdlDriver' WSDL_URL = "http://api.google.com/GoogleSearch.wsdl" google = SOAP::WSDLDriverFactory.new(WSDL_URL).createDriver types = google.wsdl_mapping_registry.definedtypes types.each {|e| content = e.content name = e.name if content.to_s =~ /Sequence/ puts "name: %s" % name puts "classname: %s" % name.class.name puts "content: %s" % content.class.name content.elements.each {|c| puts c.name puts c.type } end }It prints out stuff like this which is the doGoogleSearch() method with its arg names and types:
name: {urn:GoogleSearch}doGoogleSearch classname: XSD::QName content: WSDL::XMLSchema:: Sequence {}key {http://www.w3.org/2001/XMLSchema}string {}q {http://www.w3.org/2001/XMLSchema}string {}start {http://www.w3.org/2001/XMLSchema}int {}maxResults {http://www.w3.org/2001/XMLSchema}int {}filter {http://www.w3.org/2001/XMLSchema}boolean ...That needs to be converted to a DCOP type signature, along with some ruby code for the corresponding method to access the soap service.
k_dcop 'QStringList doGoogleSearch(QString,QString,int,int,bool,QString,bool,QString,QString,QString)' def doGoogleSearch(key, q, start, maxResults, filter, restrict, safeSearch, lr, ie, oe) result = @google.doGoogleSearch(key, q, start, maxResults, filter, restrict, safeSearch, lr, ie, oe) result.resultElements.each do |ele| puts "== #{html2rd(ele.title)}: #{ele.URL}" puts html2rd(ele.snippet) puts end endNot exactly related -- KDE Plugins in ruby
Is there a way to create KDE Plugins in Ruby (Say, a kate plugin?)? If so, is there any documentation or examples of how to do this?
Re: KDE Plugins in ruby
No, at the moment only the kdelibs and Qt headers are parsed to build the Smoke library. So it is very monolithic at the moment and some work needs to be done before Smoke can be split up into seperate libraries for the various KDE plugin interfaces.