Skip to main content

Change Skype status with QtDbus

Posted in

I will start this post with a small introduction. I'm using pomodoro technique in my work and use a timer for that. The problem I bumped into was that there is no cross platform pomodoro timer. There are plenty of them for Windows and some of them are really nice and I would use some of them if I hadn't worked on FreeBSD and Linux. So, as everybody has already understood I wrote my own timer called qomodoro. It is written in C++ with using Qt libraries. If some of you are interested you can take a loot at it here.

So, back to the point. I wanted my timer to change my skype status to "Do not Disturb" when I start pomodoro. And it does make sense that on a pomodoro start I start doing my work and therefore "Do not Disturb" status is the most appropriate to indicate that I'm busy. The same with stopping a pomodoro, on stop I want to switch back to "Online" status.

So, since I use Qt I decided to use Qt bindings for DBus. Here's what I got:

if (QDBusConnection::sessionBus().isConnected()) {
    QString skypeServiceName("com.Skype.API");
    QDBusInterface iface(skypeServiceName, "/com/Skype", "com.Skype.API", QDBusConnection::sessionBus());
    if (iface.isValid()) {
        // tell Skype that an application called qomodoro wants to communicate with it
        QDBusReply<QString> reply ="Invoke", "NAME qomodoro");
        if (reply.isValid()) {
            // specify the protocol
            reply ="Invoke", "PROTOCOL 1");
            if (reply.isValid()) {
                // set status
                reply ="Invoke", QString("SET USERSTATUS %1").arg(iStatusName)); 

Skype API reference can be found here.

Call a slot when a new chat-message arrives

Thanks! That helped me a lot!

Do I have to check for new chat-messages every few seconds or is there a way to call a slot when a new message arrives? If there is a way, how do I connect the signal to a slot in my QT-project?

C_Classic (german)

Re: Call a slot when a new chat-message arrives

Frankly speaking I have never done this, but according to the API reference you should use Notify method (instead of Invoke that I used) specifying what kind of notification you are interested in (see Notifications chapter in that reference). And I would also look at QDBusConnection::callWithCallback function and QDBusMessage class. I think they should do the trick.

switch on skype is off??


how can we switch on skype if it is off???? or the othe way around using dbus??

Re: switch on skype is off??

I'm not sure this is possible. If skype is off then it means it is not registered on dbus and therefore doesn't listen for any events on its bus.

Post new comment

The content of this field is kept private and will not be shown publicly.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.