Skip to content

Commit cf29bce

Browse files
committed
Merge branch 'release/2.5.2'
2 parents 69662c0 + fb7bbae commit cf29bce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2891
-1240
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include yowsup/common/mime.types

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Z9KKEUVYEY6BN" target="_blank"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" /></a>
44

5-
## Updates (April 1, 2016)
6-
Yowsup v2.4.102 is out, See [release notes](https://github.com/tgalal/yowsup/releases/tag/v2.4.102)
5+
## Updates (March 23, 2017)
6+
Yowsup v2.5.2 is out, See [release notes](https://github.com/tgalal/yowsup/releases/tag/v2.5.2)
77

88
==========================================================
99

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import platform
66
import sys
77

8-
deps = ['python-dateutil', 'argparse', 'python-axolotl>=0.1.7']
8+
deps = ['python-dateutil', 'argparse', 'python-axolotl>=0.1.35', 'six']
99

1010
if sys.version_info < (2,7):
1111
deps += ['importlib']
@@ -33,6 +33,7 @@
3333
#long_description=long_description,
3434
packages= find_packages(),
3535
include_package_data=True,
36+
data_files = [('yowsup/common', ['yowsup/common/mime.types'])],
3637
platforms='any',
3738
#test_suite='',
3839
classifiers = [

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
[tox]
77
skip_missing_interpreters = true
8-
envlist = py26, py27, py32, py33, py34, py35
8+
envlist = py26, py27, py32, py33, py34, py35, py36
99

1010
[testenv]
1111
commands = nosetests yowsup

yowsup/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "2.4.103"
1+
__version__ = "2.5.2"
22
__author__ = "Tarek Galal"

yowsup/common/optionalmodules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(self, failMessage = None, require = False):
4040
class AxolotlOptionalModule(OptionalModule):
4141
def __init__(self, failMessage = None, require = False):
4242
super(AxolotlOptionalModule, self).__init__("axolotl",
43-
failmessage=failMessage,
43+
failMessage=failMessage,
4444
require=require)
4545

4646
if __name__ == "__main__":

yowsup/common/tools.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import time,datetime,re, hashlib
2+
import calendar
23
from dateutil import tz
34
import os
45
from .constants import YowConstants
@@ -107,9 +108,8 @@ def utcToLocal(dt):
107108

108109
@staticmethod
109110
def utcTimestamp():
110-
#utc = tz.gettz('UTC')
111111
utcNow = datetime.datetime.utcnow()
112-
return TimeTools.datetimeToTimestamp(utcNow)
112+
return calendar.timegm(utcNow.timetuple())
113113

114114
@staticmethod
115115
def datetimeToTimestamp(dt):
@@ -152,8 +152,10 @@ def generatePreviewFromImage(image):
152152
class MimeTools:
153153
MIME_FILE = os.path.join(os.path.dirname(__file__), 'mime.types')
154154
mimetypes.init() # Load default mime.types
155-
mimetypes.init([MIME_FILE]) # Append whatsapp mime.types
156-
decode_hex = codecs.getdecoder("hex_codec")
155+
try:
156+
mimetypes.init([MIME_FILE]) # Append whatsapp mime.types
157+
except exception as e:
158+
logger.warning("Mime types supported can't be read. System mimes will be used. Cause: " + e.message)
157159

158160
@staticmethod
159161
def getMIME(filepath):

yowsup/demos/cli/layer.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
import datetime
99
import os
1010
import logging
11-
from yowsup.layers.protocol_receipts.protocolentities import *
1211
from yowsup.layers.protocol_groups.protocolentities import *
1312
from yowsup.layers.protocol_presence.protocolentities import *
1413
from yowsup.layers.protocol_messages.protocolentities import *
15-
from yowsup.layers.protocol_acks.protocolentities import *
1614
from yowsup.layers.protocol_ib.protocolentities import *
1715
from yowsup.layers.protocol_iq.protocolentities import *
1816
from yowsup.layers.protocol_contacts.protocolentities import *
@@ -25,7 +23,6 @@
2523
from yowsup.common.optionalmodules import PILOptionalModule, AxolotlOptionalModule
2624

2725
logger = logging.getLogger(__name__)
28-
2926
class YowsupCliLayer(Cli, YowInterfaceLayer):
3027
PROP_RECEIPT_AUTO = "org.openwhatsapp.yowsup.prop.cli.autoreceipt"
3128
PROP_RECEIPT_KEEPALIVE = "org.openwhatsapp.yowsup.prop.cli.keepalive"
@@ -78,6 +75,7 @@ def jidToAlias(self, jid):
7875
def setCredentials(self, username, password):
7976
self.getLayerInterface(YowAuthenticationProtocolLayer).setCredentials(username, password)
8077

78+
return "%s@s.whatsapp.net" % username
8179

8280
@EventCallback(EVENT_START)
8381
def onStart(self, layerEvent):
@@ -343,13 +341,6 @@ def keys_get(self, jids):
343341
entity = GetKeysIqProtocolEntity(jids)
344342
self.toLower(entity)
345343

346-
@clicmd("Send prekeys")
347-
def keys_set(self):
348-
with AxolotlOptionalModule(failMessage = self.__class__.FAIL_OPT_AXOLOTL) as axoOptMod:
349-
from yowsup.layers.axolotl import YowAxolotlLayer
350-
if self.assertConnected():
351-
self.broadcastEvent(YowLayerEvent(YowAxolotlLayer.EVENT_PREKEYS_SET))
352-
353344
@clicmd("Send init seq")
354345
def seq(self):
355346
priv = PrivacyListIqProtocolEntity()

yowsup/demos/cli/stack.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from .layer import YowsupCliLayer
33
from yowsup.layers.auth import AuthError
44
from yowsup.layers import YowLayerEvent
5-
from yowsup.layers.auth import YowAuthenticationProtocolLayer
5+
from yowsup.layers.axolotl.props import PROP_IDENTITY_AUTOTRUST
66
import sys
77

88
class YowsupCliStack(object):
@@ -16,6 +16,7 @@ def __init__(self, credentials, encryptionEnabled = True):
1616

1717
# self.stack.setCredentials(credentials)
1818
self.stack.setCredentials(credentials)
19+
self.stack.setProp(PROP_IDENTITY_AUTOTRUST, True)
1920

2021
def start(self):
2122
print("Yowsup Cli client\n==================\nType /help for available commands\n")

yowsup/demos/contacts/stack.py

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
from yowsup.stacks import YowStack
21
from .layer import SyncLayer
2+
3+
from yowsup.stacks import YowStackBuilder
4+
from yowsup.layers.auth import AuthError
35
from yowsup.layers import YowLayerEvent
4-
from yowsup.layers.auth import YowCryptLayer, YowAuthenticationProtocolLayer, AuthError
5-
from yowsup.layers.coder import YowCoderLayer
6-
from yowsup.layers.network import YowNetworkLayer
7-
from yowsup.layers.stanzaregulator import YowStanzaRegulator
8-
from yowsup.layers.protocol_receipts import YowReceiptProtocolLayer
9-
from yowsup.layers.protocol_acks import YowAckProtocolLayer
10-
from yowsup.layers.logger import YowLoggerLayer
11-
from yowsup.layers.protocol_contacts import YowContactsIqProtocolLayer
12-
from yowsup.layers import YowParallelLayer
6+
from yowsup.layers.auth import YowAuthenticationProtocolLayer
7+
from yowsup.layers.network import YowNetworkLayer
138

149
class YowsupSyncStack(object):
1510
def __init__(self, credentials, contacts, encryptionEnabled = False):
@@ -19,30 +14,13 @@ def __init__(self, credentials, contacts, encryptionEnabled = False):
1914
:param encryptionEnabled:
2015
:return:
2116
"""
22-
if encryptionEnabled:
23-
from yowsup.layers.axolotl import YowAxolotlLayer
24-
layers = (
25-
SyncLayer,
26-
YowParallelLayer([YowAuthenticationProtocolLayer, YowContactsIqProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer]),
27-
YowAxolotlLayer,
28-
YowLoggerLayer,
29-
YowCoderLayer,
30-
YowCryptLayer,
31-
YowStanzaRegulator,
32-
YowNetworkLayer
33-
)
34-
else:
35-
layers = (
36-
SyncLayer,
37-
YowParallelLayer([YowAuthenticationProtocolLayer, YowContactsIqProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer]),
38-
YowLoggerLayer,
39-
YowCoderLayer,
40-
YowCryptLayer,
41-
YowStanzaRegulator,
42-
YowNetworkLayer
43-
)
17+
stackBuilder = YowStackBuilder()
18+
19+
self.stack = stackBuilder \
20+
.pushDefaultLayers(encryptionEnabled) \
21+
.push(SyncLayer) \
22+
.build()
4423

45-
self.stack = YowStack(layers)
4624
self.stack.setProp(SyncLayer.PROP_CONTACTS, contacts)
4725
self.stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True)
4826
self.stack.setCredentials(credentials)

0 commit comments

Comments
 (0)