Ubuntu DBus and Upstart - Service controller



  • Hello,

    Been working on a large project that uses QService to create a service. One of the applications I want the abilty to control the service via the local system API. For example on windows I will use the Service Controller API, i have some working code out on my site, "Void Realms Source Code":http://voidrealms.com/index.php?r=source/view&id=22

    But my question here is specifically with upstart on Ubuntu. Upstart has a DBus interface which is fairly new to me:
    "Upstart DBus":http://upstart.ubuntu.com/wiki/DBusInterface

    I did find an example, but for the life of me I cant get it to work - error arguments are incorrect:
    "DBus example with Upstart":https://gitorious.org/chakra/kcm-systemd/source/706ef9bdbbca3172d478d53a568d1f8321a95b95:tests/trainingtests.cpp

    Can anyone point me in the right direction or show me a working example of how to query Upstart via DBus? Ideally I would like to be able to start / stop and query the service state.

    Thanks!

    [Update]
    Thought i had this solved but found I am still a long ways off...so far the only thing I can get working is getting a list of job paths from the Upstart dbus interface.

    Working code is:

    Pro file:
    qt += dbus

    Code file:

    @void test::performTest()
    {
    QDBusInterface interface(
    QLatin1String("com.ubuntu.Upstart"),
    QLatin1String("/com/ubuntu/Upstart"),
    QLatin1String("com.ubuntu.Upstart0_6"),
    QDBusConnection::systemBus()
    );

    qDebug() << "Getting all jobs";
    
    QDBusReply< QList<QDBusObjectPath> > reply = interface.call("GetAllJobs");
    if(reply.isValid())
    {
        foreach(QDBusObjectPath obj, reply.value())
        {
            qDebug() << "PATH = " << obj.path() << "\r\n";
        }
    }
    else
    {
        qDebug() << reply.error();
    }
    

    }@

    Even after reviewing the documentation I am still a bit lost - anyone have any experience controlling upstart jobs via DBus or should I just fire off a QProcess and read the output of initctl?



  • bump -


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.