I am trying to understand how to use dbus with pidgin

My problem is that I'm not sure how to connect them. Does pidgin need to be installed in a certain way so that dbus can interact with it? and if not, should pidgin gui work for dbus to use it?

+4
source share
5 answers

By this source you can do the following:

#!/usr/bin/env python def cb_func(account, rec, message): #change message here somehow? print message import dbus, gobject from dbus.mainloop.glib import DBusGMainLoop dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) bus = dbus.SessionBus() bus.add_signal_receiver(cb_func, dbus_interface="im.pidgin.purple.PurpleInterface", signal_name="SendingImMsg") loop = gobject.MainLoop() loop.run() 

Perhaps you can start with this guide.

+5
source
 import dbus from dbus.mainloop.glib import DBusGMainLoop main_loop = DBusGMainLoop() session_bus = dbus.SessionBus(mainloop = main_loop) obj = session_bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") 

Then you can use the purple object to call some methods:

 status = purple.PurpleSavedstatusNew("", current) purple.PurpleSavedstatusSetMessage(status, message) purple.PurpleSavedstatusActivate(status) 
+4
source

A really useful tool to use when using DBUS to interact with Pidgin D-Feet . You can view all the available methods that you can call, and even execute them directly from the GUI.

+2
source

The code below shows an example of displaying a contact list when it is hidden, and another example of starting an IM chat with a specific contact.

 import dbus BUS_ARGS = ('im.pidgin.purple.PurpleService', '/im/pidgin/purple/PurpleObject') obj = dbus.SessionBus().get_object(*BUS_ARGS) purple = dbus.Interface(obj, 'im.pidgin.purple.PurpleInterface') # show buddy list if it is hidden purple.PurpleBlistSetVisible(1) # start IM conversation with specific contact account = purple.PurpleAccountsFindConnected('', '') conversation = purple.PurpleConversationNew(1, account, ' alice@example.com ') 

I can recommend a number of useful resources related to using dbus with pidgin:

  • Top D-Bus with Pidgin - Has three separate python dbus examples.
  • purple-remote is a python script that was installed on my ubuntu machine when I installed pidgin. Its a single file and quite easy to read.
  • dbus-monitor is an excellent program for monitoring dbus calls. This can help you find out what calls your programs use when you cannot find them documented.
  • qdbusviewer is a great graphical tool that can display pidgins dbus methods. You can also call them from the tool itself.

qdbusviewer

+2
source

You do not need to make any special Pidgin configuration to use D-Bus, however it should work if you want to use it. You can check the script that I use to control the Pidgin status from the NetworkManager manager ( part 1 , part 2 ) as an example of how to connect Pidgin via D-Bus with python.

0
source

All Articles