Add logout event and disable call

This commit is contained in:
moyamo 2015-02-27 14:58:32 +02:00
parent 1878a30fb6
commit 9fc0dc7333

View file

@ -29,6 +29,7 @@ import time
from yowsup.stacks import YowStack from yowsup.stacks import YowStack
from yowsup.layers import YowLayerEvent from yowsup.layers import YowLayerEvent
from yowsup.layers import YowParallelLayer
from yowsup.layers.auth import (YowCryptLayer, YowAuthenticationProtocolLayer, from yowsup.layers.auth import (YowCryptLayer, YowAuthenticationProtocolLayer,
AuthError) AuthError)
from yowsup.layers.coder import YowCoderLayer from yowsup.layers.coder import YowCoderLayer
@ -79,11 +80,11 @@ class Session:
env.CURRENT_ENV = env.S40YowsupEnv() env.CURRENT_ENV = env.S40YowsupEnv()
layers = ( layers = (
(YowAuthenticationProtocolLayer, YowParallelLayer((YowAuthenticationProtocolLayer,
YowMessagesProtocolLayer, YowMessagesProtocolLayer,
YowReceiptProtocolLayer, YowReceiptProtocolLayer,
YowAckProtocolLayer, YowAckProtocolLayer,
YowMediaProtocolLayer), YowMediaProtocolLayer)),
YowCoderLayer, YowCoderLayer,
YowCryptLayer, YowCryptLayer,
YowStanzaRegulator, YowStanzaRegulator,
@ -98,13 +99,10 @@ class Session:
def call(self, method, args = ()): def call(self, method, args = ()):
args = [str(s) for s in args] args = [str(s) for s in args]
self.logger.debug("%s(%s)", method, ", ".join(args)) self.logger.debug("%s(%s)", method, ", ".join(args))
self.frontend.methodInterface.call(method, args) # self.frontend.methodInterface.call(method, args)
def listen(self, event, callback):
self.frontend.signalInterface.registerListener(event, callback)
def logout(self): def logout(self):
self.call("disconnect", ("logout",)) self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_DISCONNECT))
def login(self, password): def login(self, password):
self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, self.stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS,