This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

Describe Vala/DBus here. This is some ideas.

Introduction

Full flexible DBus supporting is important for vala:

Inherited Members

Inherieted members are also member of current class. Thus they should be treated equally.

Visibility Issue

Task Tracking

Things to be done:

  1. signals, from the base class and from the class
  2. properties, from the base class and from the class
  3. overriden methods
  4. void return value
  5. string[] return value
  6. Transparent object access, if fails, use 7
  7. lookup registered object from a connection.

So far has been done at svn://gnome2-globalmenu.googlecode.com/svn/branches/0.6-devel/vala/ (in the patch files)

  1. done, [DBus (signals = "sig1, sig2")]; Bug 531132

  2. intrepolation is done, [DBus (properties = "p1, p2")] but no dynamic object supporting yet; Bug 531132;

  3. done, using the parent class method cname; Bug 531132 and Bug 531135;
  4. not done; don't know why it fails.
  5. string[] return value; finished in Bug 530455 and Bug 531251, also Bug 529351.
  6. not easy to done(DBus returns a DBusGObjectPath, which is a string) and not seeming to be reliable.
  7. done in dbus-glib-1.vapi (weak Object DBus.Connection::lookup_object(string path)); Bug 531131

Use Case

Then it follows a piece of example code, which is excepted to work after all are done:

Server side code:

class Funk : Object {
  public void signal funky();
  public virtual void funk() {
    funky();
  }
}

[DBus (name = "org.gnome.TestServer", signals = "funky, echo", properties = "name, mess")]
class TestServer: Funk {
  public string name {get; construct;}
  public string mess {get; set;}

  public TestServer(string name) {
     this.name = name;
  }
  construct {
     mess = name;
  }
  public void signal echo(string msg);
  public override void funk() {
    base.funk();
  }
  public string ping(string msg) {
    message(msg);
    echo(mess);
  }

  public void main(string[] args){
     MainLoop loop = new MainLoop(..);
     .... Setup dbus connection....
     TestServer server = new TestServer("funky server");
     conn.register_object("/org/gnome/TestServer", server);
     loop.run();
  }
}

Client side code

   public void main(string[] args {
     ... Setup dbus connection...
     var server = conn.get_object(..., "/org/gnome/TestServer", ......);
     server.echo += (o, s) => {
        message(s);
     };
     server.funky += (o) => {
        message("funky signal received");
     };
     server.ping("pingping ping");
     server.mess = "messy echo";
     server.ping("ping a mess");

   }

2024-10-23 11:37