def h_authorize(self, _): """ Bus message handler """ ahandler=AuthResponseAgent() Bus.publish(self, "method_call", {"method":"auth.getToken"}, {"c":ahandler.h_apicb, "e":ahandler.h_apieb})
def on_cenable_toggled(self, wcenable): """ DBus API enable checkbox """ state=wcenable.props.active Bus.publish(self, "user_params", {"dbus_enable": str(state)}) return True
def h_apieb(self, response): """ API response errback """ _,code, msg=response tcode=self._msgTable.get(code, "unknown") Bus.publish(self, "error", tcode) Bus.publish(self, "log", "Authorization error, code(%s) msg(%s)" % (code, msg))
def _publishParams(self, params={}): """ Publish any change """ for param in self._paramsList: wgt=self.builder.get_object("e%s"%param) value=wgt.get_text() params[param]=value Bus.publish(self, "user_params", params)
def on_bauth_clicked(self, wbauth): Bus.publish(self, "authorize") return True
def show(self): Bus.publish(self, "user_params?") self.bapply.props.sensitive=False self.window.present()
def gatePublish(self, *pa): if self._enable: Bus.publish(self, *pa)
def __init__(self): bus_name = dbus.service.BusName('fm.lastfm.api', bus=dbus.SessionBus()) dbus.service.Object.__init__(self, bus_name, '/account') self._cache={} self._enable=False Bus.publish(self, "user_params?")