Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm trying to figure out how to use dbus with pidgin

Tags:

python

dbus

My problem is I'm not sure how to interface them. Do I need to have pidgin installed in a particular way in order for dbus to interface with it? and if not does the pidgin gui have to be running in order for dbus to utilize it?

like image 490
Ryan Avatar asked Dec 13 '22 03:12

Ryan


2 Answers

As per this source you could 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()

Probably you can get started with this lead.

like image 198
Kevin Boyd Avatar answered Dec 28 '22 01:12

Kevin Boyd


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 like this:

status = purple.PurpleSavedstatusNew("", current)
purple.PurpleSavedstatusSetMessage(status, message)
purple.PurpleSavedstatusActivate(status)
like image 36
markuz Avatar answered Dec 27 '22 23:12

markuz