Hello, i've had the same problem some time ago and wrote a simple wrapper class for communicating with skype (attached).
This way there were no clashes with existing library functions.
In addition the wrapper handles asynchronous messages sent from
skype an delegates them using signals (the current skype dbus example
lacks this).
I had trouble to set this up correctly, so maybe someone can make use
of this.
Usage is as simple as:
skype = new Skype.DBusWrapper();
skype.connected.connect(() => {
stdout.printf("Skype DBus Service online\n");
});
skype.disconnected.connect(() => {
stdout.printf("Skype DBus Service offline\n");
});
skype.notified.connect((msg) => {
stdout.printf("Incoming Skype notification: %s\n", msg);
});
skype.send("NAME skype-test-client");
skype.send("PROTOCOL 8");
Regards
namespace Skype {
[DBus (name = "com.Skype.API")]
public interface SkypeAPI : GLib.Object {
public abstract string Invoke (string command) throws IOError;
}
[DBus (name = "com.Skype.API.Client")]
public class SkypeListener : GLib.Object {
public void Notify (string command) {
this.notified(command);
}
[DBus (visible = false)]
public signal void notified (string command);
}
public class DBusWrapper : GLib.Object {
SkypeListener listener;
SkypeAPI proxy;
public signal void connected ();
public signal void disconnected ();
public signal void notified (string command);
public string? send (string command) {
try {
return this.proxy.Invoke(command);
} catch (IOError e) {
return null;
}
}
public DBusWrapper () {
this.listener = new SkypeListener ();
this.listener.notified.connect((s) => this.notified(s));
try {
Bus.get_sync (BusType.SESSION).register_object ("/com/Skype/Client", this.listener);
Bus.watch_name (BusType.SESSION, "com.Skype.API", BusNameWatcherFlags.NONE, (conn, name, owner) => {
try {
this.proxy = Bus.get_proxy_sync(BusType.SESSION, name, "/com/Skype");
} catch (IOError e) {
}
this.connected();
}, (conn, name) => {
this.proxy = null;
this.disconnected();
});
} catch (IOError e) {
}
}
}
}
signature.asc
Description: PGP signature
_______________________________________________ vala-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/vala-list
