External Handler Proof of Concept

Kero van Gelder kero at chello.nl
Fri Jul 27 00:30:15 CEST 2007


>> I'll think about the extension concept a bit more. The fact that you chose
>> a scenario to modify a phone number is interesting. How about calling a 
>> person from a Contact? and then choosing VoIP or GSM by those extensions?
>> (specifically, I do not think gsmd is the place where the call should
>> originate, in the image you have on the Wiki).
[snip reason]

> That said, I agree that you would probably want to put another (similar) 
> extension method in to the dialer.  If you had such a method in the dialer 
> then it could tell the dialer to initiate VoIP rather than GSM, in which 
> case the GSM extension method would never be called as you wouldn't go down 
> that codepath.  The more extension calls we have the more flexibility we 
> have, although there is a balance between having them everywhere with 
> no-one knowing to which one they should attach their extension and having 
> them in very few places thus limiting the ability to extend the base 
> product.

Indeed, we'll need more than one place to hook in, but not too many places.

Something I thought of, the application (or whatever) that might want to
register an extension need not be started yet. After all, DBus is capable
of starting applications (and I'm sure Contacts, Agenda and a few more
will be in the nearby future).
So at least for choosing VoIP or GSM, the system-dbus must tell what's
available and Contacts must tell how we can reach the person at all.
I think *calling* Contacts is more suitable than letting it register an
extension, for this case.

What do you think?

> In terms of bindings, what I really need to do is put together the D-Bus 
> methods to register/unregister an extension and for the extension handler 
> to call the extensions dynamically.  At that stage you'll be able to 
> integrate your Ruby code very easily.  I'll give it a crack over the next 
> couple of days and see what I can put together.  Watch this space, as they 
> say...

Same here, polished my code, you can now use it like in the two little
attachments. It's not as clean as Ruby can be, yet, but it's rather close
now. I'm also happy to have freedesktop.* in a separate file, now.

I bet I can
  ext_handler = DBus.proxy.new("org.openmoko.ef.eh.Gsmd", "/org/openmoko/ef/eh/Gsmd/, "org.openmoko.ef.eh.Gsmd")
  ext_handler.call("method", "sig", arg0, arg1, ...)
already :)

update on http://chmeee.dyndns.org/git/?p=dbus/.git;a=summary

Bye,
Kero.
-------------- next part --------------
require 'dbus/connection'

# become GSMD
DBus.freedesktop.demand_name("org.openmoko.GSMD")

# We'll be wanting to look in the Contacts, make a "proxy" (dbus terminology)
contacts = DBus::Proxy.new(DBus.session, "org.openmoko.Contacts", "/org/openmoko/Contacts", "org.openmoko.Contacts")

counter = 0
loop {
  counter += 1
  phone_number = (1024_000+counter).to_s

  # pretend there is an incoming call
  DBus.session.emit("org.openmoko.Call", "Incoming", "s", phone_number)

  # Look up the caller ID in the Contacts
  p contacts.call("WhoIs", "s", phone_number)

  sleep 1
}
                    
-------------- next part --------------
require 'dbus/match_rules'

DBus.freedesktop.demand_name("org.openmoko.Contacts")

DBus.session.listen_for(DBus::Interface=>"org.openmoko.Call", DBus::Member=>"Incoming") {|msg|
  puts "Incoming call from #{msg.body} !"
}

DBus.session.publish_method("org.openmoko.Contacts", "WhoIs") {|msg|
  DBus.session.reply_to(msg, "s", "John")
}

sleep 1234567890


More information about the community mailing list