D-Bus (presentation)
From RHLUG
Contents |
[edit] Presentation
The presentation is available here: D-Bus Presentation
[edit] Example
The examples I showed aren't in the slides, so I included the code for one here; the others are similar. This is how to open a new conversation window from YOUR_SN to TARGET_SN in Pidgin. There's an example using the command-line tool 'dbus-send' and an example in Python using the Python D-Bus binding.
[edit] Command-Line
File: pidgin-msg.sh
account=$(
dbus-send --print-reply \
--type=method_call \
--dest=im.pidgin.purple.PurpleService \
/im/pidgin/purple/PurpleObject \
im.pidgin.purple.PurpleInterface.PurpleAccountsFind \
string:YOUR_SN \
string:prpl-aim \
| tail -n1 \
| cut -d' ' -f5
)
dbus-send --print-reply \
--type=method_call \
--dest=im.pidgin.purple.PurpleService \
/im/pidgin/purple/PurpleObject \
im.pidgin.purple.PurpleInterface.PurpleConversationNew \
uint32:1 \
int32:$account \
string:TARGET_SN
[edit] Python
File: pidgin-msg.py
import dbus
bus = dbus.SessionBus()
obj = bus.get_object('im.pidgin.purple.PurpleService', '/im/pidgin/purple/PurpleObject')
pidgin = dbus.Interface(obj, 'im.pidgin.purple.PurpleInterface')
account = pidgin.PurpleAccountsFind(YOUR_SN, 'prpl-aim')
conv = pidgin.PurpleConversationNew(1, account, TARGET_SN)

