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

Andre Moreira Magalhaes andre.magalhaes at collabora.co.uk
Wed Sep 23 13:46:04 PDT 2009


The code seems ok, except it's missing qRegisterMetatype for 
ParametersDefinition/List. You can also try TelepathyQt4 
ConnectionManager API, it does that for you, and also reads from manager 
file if available.

BR
Andrunko

chen zheng wrote:
> 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 <http://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
> ------------------------------------------------------------------------
>
> _______________________________________________
> telepathy mailing list
> telepathy at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/telepathy
>   



More information about the telepathy mailing list