separated axolotol layers, use android env

This commit is contained in:
git-o-bot 2016-04-19 21:10:05 +02:00
parent 5b7f8c9646
commit 5063966772

View file

@ -10,7 +10,7 @@ from yowsup.layers import YowLayerEvent, YowParallelLayer
from yowsup.layers.auth import AuthError from yowsup.layers.auth import AuthError
# Layers # Layers
from yowsup.layers.axolotl import YowAxolotlLayer from yowsup.layers.axolotl import AxolotlSendLayer, AxolotlControlLayer, AxolotlReceivelayer
from yowsup.layers.auth import YowCryptLayer, YowAuthenticationProtocolLayer from yowsup.layers.auth import YowCryptLayer, YowAuthenticationProtocolLayer
from yowsup.layers.coder import YowCoderLayer from yowsup.layers.coder import YowCoderLayer
from yowsup.layers.logger import YowLoggerLayer from yowsup.layers.logger import YowLoggerLayer
@ -58,38 +58,9 @@ from functools import partial
#from session import MsgIDs #from session import MsgIDs
# Temporarily work around yowsup padding bugs with new protocol
class UpdatedYowAxolotlLayer(YowAxolotlLayer):
def decodeInt7bit(self, string):
idx = 0
while ord(string[idx]) >= 128:
idx += 1
consumedBytes = idx + 1
value = 0
while idx >= 0:
value <<= 7
value += ord(string[idx]) % 128
idx -= 1
return value, consumedBytes
def unpadV2Plaintext(self, v2plaintext):
end = -ord(v2plaintext[-1]) # length of the left padding
length,consumed = self.decodeInt7bit(v2plaintext[1:])
return v2plaintext[1+consumed:end]
# Temporary env until yowsup updates
class UpdatedS40YowsupEnv(env.S40YowsupEnv):
_VERSION = "2.13.39"
_OS_NAME= "S40"
_OS_VERSION = "14.26"
_DEVICE_NAME = "302"
_MANUFACTURER = "Nokia"
_TOKEN_STRING = "PdA2DJyKoUrwLw1Bg6EIhzh502dF9noR9uFCllGk{phone}"
_AXOLOTL = True
class YowsupApp(object): class YowsupApp(object):
def __init__(self): def __init__(self):
env.CURRENT_ENV = UpdatedS40YowsupEnv() env.CURRENT_ENV = env.AndroidYowsupEnv()
layers = (YowsupAppLayer, layers = (YowsupAppLayer,
YowParallelLayer((YowAuthenticationProtocolLayer, YowParallelLayer((YowAuthenticationProtocolLayer,
@ -107,7 +78,8 @@ class YowsupApp(object):
YowProfilesProtocolLayer, YowProfilesProtocolLayer,
YowGroupsProtocolLayer, YowGroupsProtocolLayer,
YowPresenceProtocolLayer)), YowPresenceProtocolLayer)),
UpdatedYowAxolotlLayer, AxolotlControlLayer,
YowParallelLayer((AxolotlSendLayer, AxolotlReceivelayer)),
YowCoderLayer, YowCoderLayer,
YowCryptLayer, YowCryptLayer,
YowStanzaRegulator, YowStanzaRegulator,