View Single Post
Posts: 21 | Thanked: 8 times | Joined on Dec 2009
#3
Ok heres a python script to set status to offline on skype at Wlan disconnect. I can't test completely right now as I am roaming, so try it out and let me know.
Code:
import gobject
import dbus
from dbus.mainloop.glib import DBusGMainLoop

import subprocess

def Wlan_StDis(interf):
	acc_r=subprocess.Popen('/usr/bin/dbus-send --type=method_call --print-reply --dest=org.freedesktop.Telepathy.AccountManager /org/freedesktop/Telepathy/AccountManager org.freedesktop.DBus.Properties.Get string:org.freedesktop.Telepathy.AccountManager string:ValidAccounts | grep -m 1 skype', shell=True, stdout=subprocess.PIPE, ).communicate()[0]
	acc = acc_r[22:-2]
	print acc
	bus= dbus.SessionBus()
	accm = bus.get_object('org.freedesktop.Telepathy.AccountManager', acc)
	accm.Set('org.freedesktop.Telepathy.Account', 'RequestedPresence', \
		dbus.Struct(( dbus.UInt32(1) ,  'Offline', 'Disconnect by script' ), signature='uss'),
		dbus_interface='org.freedesktop.DBus.Properties')
DBusGMainLoop(set_as_default=True)
dbus.SystemBus().add_signal_receiver(Wlan_StDis,dbus_interface=None,signal_name="disconnected",bus_name="com.nokia.wlancond",path="/com/nokia/wlancond/signal",)
gobject.MainLoop().run()

Last edited by VII; 2010-07-14 at 08:04. Reason: Fixed code 1
 

The Following 2 Users Say Thank You to VII For This Useful Post: