Changeset 5f8ad281
- Timestamp:
- 2015-05-20T02:56:41Z (10 years ago)
- Children:
- 2b4402f
- Parents:
- 63b017e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/wa.py
r63b017e r5f8ad281 7 7 8 8 from yowsup.layers.auth import YowAuthenticationProtocolLayer 9 from yowsup.layers.protocol_acks import YowAckProtocolLayer 10 from yowsup.layers.protocol_chatstate import YowChatstateProtocolLayer 11 from yowsup.layers.protocol_contacts import YowContactsIqProtocolLayer 12 from yowsup.layers.protocol_groups import YowGroupsProtocolLayer 13 from yowsup.layers.protocol_ib import YowIbProtocolLayer 14 from yowsup.layers.protocol_iq import YowIqProtocolLayer 9 15 from yowsup.layers.protocol_messages import YowMessagesProtocolLayer 16 from yowsup.layers.protocol_notifications import YowNotificationsProtocolLayer 17 from yowsup.layers.protocol_presence import YowPresenceProtocolLayer 18 from yowsup.layers.protocol_privacy import YowPrivacyProtocolLayer 19 from yowsup.layers.protocol_profiles import YowProfilesProtocolLayer 10 20 from yowsup.layers.protocol_receipts import YowReceiptProtocolLayer 11 from yowsup.layers.protocol_acks import YowAckProtocolLayer12 21 from yowsup.layers.network import YowNetworkLayer 13 22 from yowsup.layers.coder import YowCoderLayer … … 18 27 from yowsup import env 19 28 20 from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback 21 from yowsup.layers.protocol_receipts.protocolentities import * 29 from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback 30 from yowsup.layers.protocol_acks.protocolentities import * 31 from yowsup.layers.protocol_chatstate.protocolentities import * 32 from yowsup.layers.protocol_contacts.protocolentities import * 22 33 from yowsup.layers.protocol_groups.protocolentities import * 23 from yowsup.layers.protocol_presence.protocolentities import *24 from yowsup.layers.protocol_messages.protocolentities import *25 from yowsup.layers.protocol_acks.protocolentities import *26 34 from yowsup.layers.protocol_ib.protocolentities import * 27 35 from yowsup.layers.protocol_iq.protocolentities import * 28 from yowsup.layers.protocol_contacts.protocolentities import * 29 from yowsup.layers.protocol_chatstate.protocolentities import * 36 from yowsup.layers.protocol_media.mediauploader import MediaUploader 37 from yowsup.layers.protocol_media.protocolentities import * 38 from yowsup.layers.protocol_messages.protocolentities import * 39 from yowsup.layers.protocol_notifications.protocolentities import * 40 from yowsup.layers.protocol_presence.protocolentities import * 30 41 from yowsup.layers.protocol_privacy.protocolentities import * 31 from yowsup.layers.protocol_media.protocolentities import *32 from yowsup.layers.protocol_media.mediauploader import MediaUploader33 42 from yowsup.layers.protocol_profiles.protocolentities import * 43 from yowsup.layers.protocol_receipts.protocolentities import * 34 44 from yowsup.layers.axolotl.protocolentities.iq_key_get import GetKeysIqProtocolEntity 35 45 from yowsup.layers.axolotl import YowAxolotlLayer … … 76 86 self.cb.error(entity.getReason()) 77 87 self.cb.logout(False) 88 89 def onEvent(self, event): 90 print event 91 if event.getName() == "disconnect": 92 self.getStack().execDetached(self.daemon.StopDaemon) 93 94 @ProtocolEntityCallback("presence") 95 def onPresence(self, pres): 96 print pres 78 97 79 98 @ProtocolEntityCallback("message") … … 86 105 @ProtocolEntityCallback("receipt") 87 106 def onReceipt(self, entity): 88 ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", "delivery", entity.getFrom()) 107 print "ACK THE ACK!" 108 ack = OutgoingAckProtocolEntity(entity.getId(), entity.getTag(), 109 entity.getType(), entity.getFrom()) 89 110 self.toLower(ack) 111 112 @ProtocolEntityCallback("chatstate") 113 def onChatstate(self, entity): 114 print(entity) 115 90 116 91 117 class YowsupDaemon(threading.Thread): … … 118 144 }, 119 145 } 120 ACCOUNT_FLAGS = 6 # HANDLE_DOMAINS + STATUS_MESSAGE 146 AWAY_STATES = ["Available"] 147 ACCOUNT_FLAGS = 14 # HANDLE_DOMAINS + STATUS_MESSAGE + LOCAL_CONTACTS 121 148 # TODO: LOCAL LIST CAUSES CRASH! 122 149 # TODO: HANDLE_DOMAIN in right place (add ... ... nick bug) 123 150 # TODO? Allow set_away (for status msg) even if AWAY_STATES not set? 151 # and/or, see why with the current value set_away state is None. 152 124 153 def login(self, account): 125 154 self.stack = self.build_stack(account) … … 128 157 self.daemon.start() 129 158 self.bee.log("Started yowsup thread") 159 160 self.contacts = set() 130 161 131 162 def keepalive(self): … … 142 173 def add_buddy(self, handle, _group): 143 174 self.yow.Ship(SubscribePresenceProtocolEntity(handle)) 175 # Need to confirm additions. See if this can be done based on server ACKs. 176 self.bee.add_buddy(handle, "") 144 177 145 178 def remove_buddy(self, handle, _group): 146 179 self.yow.Ship(UnsubscribePresenceProtocolEntity(handle)) 147 180 148 def set_away( _state, message):181 def set_away(self, _state, status): 149 182 # I think state is not supported? 150 print "Trying to set status to %r " % status183 print "Trying to set status to %r, %r" % (_state, status) 151 184 self.yow.Ship(SetStatusIqProtocolEntity(status)) 152 185 … … 157 190 layers = ( 158 191 BitlBeeLayer, 159 (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer) 192 193 ( 194 YowAckProtocolLayer, 195 YowAuthenticationProtocolLayer, 196 YowIbProtocolLayer, 197 YowIqProtocolLayer, 198 YowMessagesProtocolLayer, 199 YowNotificationsProtocolLayer, 200 YowPresenceProtocolLayer, 201 YowReceiptProtocolLayer, 202 ) 203 160 204 ) + YOWSUP_CORE_LAYERS 161 205
Note: See TracChangeset
for help on using the changeset viewer.