added logging
This commit is contained in:
parent
e085abddb9
commit
cb88abbdd7
|
@ -8,64 +8,76 @@ import logging
|
||||||
class WhatsAppBackend(SpectrumBackend):
|
class WhatsAppBackend(SpectrumBackend):
|
||||||
def __init__(self, io, db):
|
def __init__(self, io, db):
|
||||||
SpectrumBackend.__init__(self)
|
SpectrumBackend.__init__(self)
|
||||||
|
self.logger = logging.getLogger(self.__class__.__name__)
|
||||||
self.io = io
|
self.io = io
|
||||||
self.db = db
|
self.db = db
|
||||||
self.sessions = { }
|
self.sessions = { }
|
||||||
|
|
||||||
# self.handleBackendConfig("features", "muc", "true")
|
self.logger.debug("Backend started")
|
||||||
# self.handleBackendConfig("features", "rawxml", "true")
|
|
||||||
|
|
||||||
logging.info("initialized backend")
|
|
||||||
|
|
||||||
# RequestsHandlers
|
# RequestsHandlers
|
||||||
def handleLoginRequest(self, user, legacyName, password, extra):
|
def handleLoginRequest(self, user, legacyName, password, extra):
|
||||||
self.sessions[user] = Session(self, user, legacyName, password, extra, self.db)
|
self.logger.debug("handleLoginRequest(user=%s, legacyName=%s)", user, legacyName)
|
||||||
|
if user not in self.sessions:
|
||||||
|
self.sessions[user] = Session(self, user, legacyName, extra, self.db)
|
||||||
|
|
||||||
|
self.sessions[user].login(password)
|
||||||
|
|
||||||
def handleLogoutRequest(self, user, legacyName):
|
def handleLogoutRequest(self, user, legacyName):
|
||||||
del self.sessions[user]
|
self.logger.debug("handleLogoutRequest(user=%s, legacyName=%s)", user, legacyName)
|
||||||
|
if user in self.sessions:
|
||||||
|
self.sessions[user].logout()
|
||||||
|
del self.sessions[user]
|
||||||
|
|
||||||
def handleMessageSendRequest(self, user, buddy, message, xhtml = ""):
|
def handleMessageSendRequest(self, user, buddy, message, xhtml = ""):
|
||||||
self.sessions[user].sendMessage(buddy, message)
|
self.logger.debug("handleMessageSendRequest(user=%s, buddy=%s, message=%s)", user, buddy, message)
|
||||||
|
self.sessions[user].sendMessageToWA(buddy, message)
|
||||||
def handleVCardRequest(self, user, buddy, ID):
|
|
||||||
# TODO
|
|
||||||
pass
|
|
||||||
|
|
||||||
def handleVCardUpdatedRequest(self, user, photo, nickname):
|
|
||||||
# TODO
|
|
||||||
pass
|
|
||||||
|
|
||||||
def handleJoinRoomRequest(self, user, room, nickname, pasword):
|
def handleJoinRoomRequest(self, user, room, nickname, pasword):
|
||||||
self.sessions[user].joinRoom(room)
|
self.logger.debug("handleJoinRoomRequest(user=%s, room=%s, nickname=%s)", user, room, nickname)
|
||||||
|
self.sessions[user].joinRoom(room, nickname)
|
||||||
|
|
||||||
|
def handleStatusChangeRequest(self, user, status, statusMessage):
|
||||||
|
self.logger.debug("handleStatusChangeRequest(user=%s, status=%d, statusMessage=%s)", user, status, statusMessage)
|
||||||
|
if len(statusMessage):
|
||||||
|
self.sessions[user].changeStatusMessage(statusMessage)
|
||||||
|
|
||||||
|
self.sessions[user].changeStatus(status)
|
||||||
|
|
||||||
|
def handleBuddyUpdatedRequest(self, user, buddy, nick, groups):
|
||||||
|
self.logger.debug("handleBuddyUpdatedRequest(user=%s, buddy=%s, nick=%s, groups=%s)", user, buddy, nick, str(groups))
|
||||||
|
self.sessions[user].updateBuddy(buddy, nick, groups)
|
||||||
|
|
||||||
|
def handleBuddyRemovedRequest(self, user, buddy, groups):
|
||||||
|
self.logger.debug("handleBuddyRemovedRequest(user=%s, buddy=%s, groups=%s)", user, buddy, str(groups))
|
||||||
|
self.sessions[user].removeBuddy(buddy)
|
||||||
|
|
||||||
|
def handleTypingRequest(self, user, buddy):
|
||||||
|
self.logger.debug("handleTypingRequest(user=%s, buddy=%s)", user, buddy)
|
||||||
|
self.sessions[user].sendTypingStarted(buddy)
|
||||||
|
|
||||||
|
def handleTypedRequest(self, user, buddy):
|
||||||
|
self.logger.debug("handleTypedRequest(user=%s, buddy=%s)", user, buddy)
|
||||||
|
self.sessions[user].sendTypingStopped(buddy)
|
||||||
|
|
||||||
|
def handleStoppedTypingRequest(self, user, buddy):
|
||||||
|
self.logger.debug("handleStoppedTypingRequest(user=%s, buddy=%s)", user, buddy)
|
||||||
|
self.sessions[user].sendTypingStopped(buddy)
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
def handleBuddyBlockToggled(self, user, buddy, blocked):
|
||||||
|
pass
|
||||||
|
|
||||||
def handleLeaveRoomRequest(self, user, room):
|
def handleLeaveRoomRequest(self, user, room):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def handleStatusChangeRequest(self, user, status, statusMessage):
|
def handleVCardRequest(self, user, buddy, ID):
|
||||||
if (len(statusMessage)):
|
|
||||||
self.sessions[user].changeStatusMessage(statusMessage)
|
|
||||||
self.sessions[user].changeStatus(status)
|
|
||||||
|
|
||||||
def handleBuddyUpdatedRequest(self, user, buddy, nick, groups):
|
|
||||||
self.sessions[user].updateBuddy(buddy, nick, groups)
|
|
||||||
|
|
||||||
def handleBuddyRemovedRequest(self, user, buddy, groups):
|
|
||||||
self.sessions[user].removeBuddy(buddy)
|
|
||||||
|
|
||||||
def handleBuddyBlockToggled(self, user, buddy, blocked):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def handleTypingRequest(self, user, buddy):
|
def handleVCardUpdatedRequest(self, user, photo, nickname):
|
||||||
self.sessions[user].sendTypingStarted(buddy)
|
pass
|
||||||
|
|
||||||
def handleTypedRequest(self, user, buddy):
|
|
||||||
self.sessions[user].sendTypingStopped(buddy)
|
|
||||||
|
|
||||||
def handleStoppedTypingRequest(self, user, buddy):
|
|
||||||
self.sessions[user].sendTypingStopped(buddy)
|
|
||||||
|
|
||||||
def handleAttentionRequest(self, user, buddy, message):
|
def handleAttentionRequest(self, user, buddy, message):
|
||||||
# TODO
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def handleFTStartRequest(self, user, buddy, fileName, size, ftID):
|
def handleFTStartRequest(self, user, buddy, fileName, size, ftID):
|
||||||
|
@ -86,4 +98,3 @@ class WhatsAppBackend(SpectrumBackend):
|
||||||
def sendData(self, data):
|
def sendData(self, data):
|
||||||
self.io.sendData(data)
|
self.io.sendData(data)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue