[Telepathy] problem when QDBus invoke "GetParameters" function of telepathy-sofiasip

chen zheng funpig at gmail.com
Wed Sep 23 09:16:19 PDT 2009


Hello,

I want use QDBus invoke some function of Telepathy-sofiasip, the code as
below:

[CODE]
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QtCore/QDebug>
#include <QtDBus>

const QString CONNECTION_MANAGER_SERVICE_NAME =
"org.freedesktop.Telepathy.ConnectionManager.";
const QString CONNECTION_MANAGER_PATH_NAME =
"/org/freedesktop/Telepathy/ConnectionManager/";
const QString CONNECTION_MANAGER_INTERFACE_NAME =
"org.freedesktop.Telepathy.ConnectionManager";

class ParameterDefinition
{
public:
    QString name;
    uint flags;
    QString signature;
    QDBusVariant defaultValue;
};
typedef QList<ParameterDefinition> ParameterDefinitionList;
Q_DECLARE_METATYPE(ParameterDefinition)
Q_DECLARE_METATYPE(ParameterDefinitionList)

void dbus_init()
{
    qDebug() << "dbus init in";

    QDBusConnection bus = QDBusConnection::sessionBus();
    if( !bus.isConnected() )
    {
        qDebug() << "no connection";
        return;
    }

    QDBusInterface dbus_iface( CONNECTION_MANAGER_SERVICE_NAME + "sofiasip",
                               CONNECTION_MANAGER_PATH_NAME + "sofiasip",
                               CONNECTION_MANAGER_INTERFACE_NAME, bus);
    QDBusReply<QStringList> reply = dbus_iface.call( "ListProtocols" );
    qDebug() << "reply count = " << reply.value().count();
    foreach( QString name, reply.value() )
    {
        qDebug() << "protocols = " << name;
        QDBusReply<ParameterDefinitionList> parameters = dbus_iface.call(
"GetParameters", "sip" );
        if( parameters.isValid() )
            qDebug() << "parameters is valid";
        else
            qDebug() << "parameters is invalid";
        qDebug() << "parameters count = " << parameters.value().count();
        foreach( ParameterDefinition para, parameters.value() )
        {
            qDebug() << "parameter = " << para.name;
        }
    }

    qDebug() << "dbus init out";
}

int main(int argc, char* argv[])
{
    QApplication app(argc, argv);

    QPushButton quit("Quit");

    quit.resize(75, 30);
    quit.setFont(QFont("Times", 18, QFont::Bold));

    QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));

    quit.show();

    dbus_init();

    return app.exec();
}
[/CODE]

print out as below:

tom at tom-desktop:~/Templates/qt_demo/qt4cb/debug$ ./qt4cb
dbus init in
reply count =  1
protocols =  "sip"
parameters is invalid
parameters count =  0
dbus init out
tom at tom-desktop:~/Templates/qt_demo/qt4cb/debug$

why can't got valid return value when i invoke "GetParameters" of
Telepathy-sofiasip ?

Br
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/telepathy/attachments/20090924/2868f3ee/attachment.html 


More information about the telepathy mailing list