This forum has been archived. All content is frozen. Please use KDE Discuss instead.

KDE Telepathy - add contact to roster via cli script or dbus

Tags: None
(comma "," separated)
Murz
Registered Member
Posts
52
Karma
0
I user KDE Telepathy as corporate messanger via Jabber XMPP protocol. And I need to automate add new contacts for users via startup script.
I see that telepathy support dbus, but can't find any way or examples how I can use it. Can anybody provide some examples or howto about this?

Here http://talk.maemo.org/showthread.php?t=59856 I have found the way how to change online status via dbus.

Other telepathy components have dbus functions too, for example:
/org/freedesktop/Telepathy/Connection/gabble/jabber/%myaccount%/ContactList/subscribe
But I can't understand how to send command "Add contact" to it.

Can anybody post some example with dbus-send command that can add new contact to account?
User avatar
david_edmundson
KDE Developer
Posts
359
Karma
1
OS
DBus specification is here:
http://telepathy.freedesktop.org/spec/

We have to do 3 steps.

First we get must get the path to the connection object for an account.

dbus-send --print-reply --dest=org.freedesktop.Telepathy.AccountManager /org/freedesktop/Telepathy/Account/gabble/jabber/dedmundson_40kdetalk_2enet0 org.freedesktop.DBus.Properties.Get string:org.freedesktop.Telepathy.Account string:Connection


which returns:
variant object path "/org/freedesktop/Telepathy/Connection/gabble/jabber/davidedmundson_40kdetalk_2enet_2fkde_2dtelepathy_2d657662"

Then we need an object handle (a number) for a contactId

$ dbus-send --print-reply --dest=org.freedesktop.Telepathy.Connection.gabble.jabber.davidedmundson_40kdetalk_2enet_2fkde_2dtelepathy_2d657662 /org/freedesktop/Telepathy/Connection/gabble/jabber/david_2eedmundson_40chat_2efacebook_2ecom_2fkde_2dtelepathy_2d657662 org.freedesktop.Telepathy.Connection.RequestHandles uint32:1 array:string:foo@bar.com

which will return

array [
uint32 257
]

Then we request subscription on it.

dbus-send --print-reply --dest=org.freedesktop.Telepathy.Connection.gabble.jabber.davidedmundson_40kdetalk_2enet_2fkde_2dtelepathy_2d657662 /org/freedesktop/Telepathy/Connection/gabble/jabber/davidedmundson_40kdetalk_2enet_2fkde_2dtelepathy_2d657662 org.freedesktop.Telepathy.Connection.Interface.ContactList.RequestSubscription array:uint32:257 string:""


Personally at this point I would just use the Telepathy bindings in a small application at this point rather than parsing dbus-send.

Though if you run a corporate XMPP server, you can also inject a roster at a server level
User avatar
david_edmundson
KDE Developer
Posts
359
Karma
1
OS
As for http://talk.maemo.org/showthread.php?t=59856
you can achieve all of that with a small utility called mc-tool that is shipped with telepathy.
Murz
Registered Member
Posts
52
Karma
0
david_edmundson, thank you so much for detailed description, via "dbus-send" commands all works well!

I want move this commands to application (plan to write it in php), but at first I must understand and test how this works via command line script.

Aand mc-tool I already use for tune-up and change status of accounts.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]