signals with adaptors and interfaces
Thiago Macieira
thiago at kde.org
Mon Nov 12 04:44:50 PST 2007
Em Monday 12 November 2007 13:19:22 Vitaly V. Ch escreveu:
> On Nov 12, 2007 1:46 PM, Thiago Macieira <thiago at kde.org> wrote:
> > Em Monday 12 November 2007 12:32:01 Vitaly V. Ch escreveu:
> > > is adaptors class usable for catching/sending signals over dbus?
> >
> > "Yes" and "you probably don't want it".
> >
> > Adaptors are useful for sending signals over D-Bus. For receiving them,
> > you should connect to your own class's slots, not to slots in adaptors.
> > There's nothing technically wrong with connecting signals (of any type)
> > to slots in adaptors, but it seems wrong to do so.
>
> As I understand adaptors and interfaces classes is gates from Qt to
> dbus. But they seem unidirection.
> It's right? Or i'm wrong?
Not exactly. The one is the inverse of the other.
With an adaptor, you emit signals (Qt→D-Bus) and you receive method calls
(D-Bus→Qt). With a proxy interface, you receive signal emissions (D-Bus→Qt)
and you place method calls (Qt→D-Bus).
> for example at now I catch signals in following way:
>
> MainClass::MainClass(const QDBusConnection & _connection_)
>
> : connection(_connection_)
>
> {
> // add our D-Bus interface and connect to D-Bus
> new Sim300Adaptor(this);
> connection.registerObject("/", this);
>
> connection.connect(QString(), QString(), "com.i_zum.sim300",
> "send_data", this, SLOT(countersSlot(QByteArray)));
> connection.connect(QString(), QString(), "com.i_zum.sim300",
> "get_money_atd", this, SLOT(get_money_atd()));
> connection.connect(QString(), QString(), "com.i_zum.sim300",
> "get_money_cusd", this, SLOT(get_money_cusd()));
> connection.connect(QString(), QString(), "com.i_zum.sim300",
> "get_csq", this, SLOT(get_csq()));
> connection.connect(QString(), QString(), "com.i_zum.sim300",
> "get_opers_list", this, SLOT(get_opers_list()));
> connection.connect(QString(), QString(), "com.i_zum.sim300",
> "set_oper", this, SLOT(set_oper(QString)));
> }
You're using wildcard connections, so the code above is syntactically correct.
It just seems odd that you're connecting signals called get-something. Your
signal design seems weird, to say the least.
> > > And is interface class usable for sending signal to dbus or only for
> > > catching?
> >
> > You cannot emit signals for a proxy interface class. You can only emit
> > signals from objects you have registered -- therefore, adaptors only.
> >
> > But you can connect to any proxy interface object's signals as if they
> > were normal Qt signals.
>
> Hm, May be I'm wrong than adaptors is for service and interfaces for
> clients and both require both of them?
You're correct.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freedesktop.org/archives/dbus/attachments/20071112/870c3d53/attachment.pgp
More information about the dbus
mailing list