Exemplo n.º 1
0
    def recvNotification(self, node):
        if node["type"] == "picture":
            if node.getChild("set"):
                self.toUpper(
                    SetPictureNotificationProtocolEntity.fromProtocolTreeNode(
                        node))
            elif node.getChild("delete"):
                self.toUpper(
                    DeletePictureNotificationProtocolEntity.
                    fromProtocolTreeNode(node))
            else:
                self.raiseErrorForNode(node)
        elif node["type"] == "status":
            self.toUpper(
                StatusNotificationProtocolEntity.fromProtocolTreeNode(node))
        elif node["type"] == "features":
            # Not implemented
            pass
        elif node["type"] in ["contacts", "subject", "w:gp2"]:
            # Implemented in respectively the protocol_contacts and protocol_groups layer
            pass
        elif node["type"] == "contacts":
            pass
        elif node["type"] == "web":
            # Not implemented
            pass
        #else:
        #pass
        # self.raiseErrorForNode(node)

        ack = OutgoingAckProtocolEntity(node["id"], "notification",
                                        node["type"], node["from"])
        self.toLower(ack.toProtocolTreeNode())
Exemplo n.º 2
0
    def recvNotification(self, node):
        if node["type"] == "picture":
            if node.getChild("set"):
                self.toUpper(SetPictureNotificationProtocolEntity.fromProtocolTreeNode(node))
            elif node.getChild("delete"):
                self.toUpper(DeletePictureNotificationProtocolEntity.fromProtocolTreeNode(node))
            else:
                self.raiseErrorForNode(node)
        elif node["type"] == "status":
            self.toUpper(StatusNotificationProtocolEntity.fromProtocolTreeNode(node))
        elif node["type"] == "features":
            # Not implemented
            pass
        elif node["type"] in ["contacts", "subject", "w:gp2"]:
            # Implemented in respectively the protocol_contacts and protocol_groups layer
            pass
        elif node["type"] in ["features", "contacts", "web", "location"]:
            # implement individually at some point
            # but keep this pass block so system doesn't crash on these types
            pass
        else:
            self.raiseErrorForNode(node)

        ack = OutgoingAckProtocolEntity(node["id"], "notification", node["type"], node["from"])
        self.toLower(ack.toProtocolTreeNode())
Exemplo n.º 3
0
    def recvNotification(self, node):
        if node["type"] == "picture":
            if node.getChild("set"):
                self.toUpper(
                    SetPictureNotificationProtocolEntity.fromProtocolTreeNode(
                        node))
            elif node.getChild("delete"):
                self.toUpper(
                    DeletePictureNotificationProtocolEntity.
                    fromProtocolTreeNode(node))
            else:
                self.raiseErrorForNode(node)
        elif node["type"] == "status":
            self.toUpper(
                StatusNotificationProtocolEntity.fromProtocolTreeNode(node))
        elif node["type"] in ["contacts", "subject", "w:gp2"]:
            # Implemented in respectively the protocol_contacts and protocol_groups layer
            pass
        else:
            logger.warning("Unsupported notification type: %s " % node["type"])
            logger.debug("Unsupported notification node: %s" % node)

        ack = OutgoingAckProtocolEntity(node["id"],
                                        "notification",
                                        node["type"],
                                        node["from"],
                                        participant=node["participant"])
        self.toLower(ack.toProtocolTreeNode())
Exemplo n.º 4
0
    def recvNotification(self, node):
        if node["type"] == "picture":
            if node.getChild("set"):
                self.toUpper(SetPictureNotificationProtocolEntity.fromProtocolTreeNode(node))
            elif node.getChild("delete"):
                self.toUpper(DeletePictureNotificationProtocolEntity.fromProtocolTreeNode(node))
            else:
                self.raiseErrorForNode(node)
        elif node["type"] == "status":
            self.toUpper(StatusNotificationProtocolEntity.fromProtocolTreeNode(node))
        elif node["type"] == "features":
            # Not implemented
            pass
        elif node["type"] in [ "contacts", "subject", "w:gp2" ]:
            # Implemented in respectively the protocol_contacts and protocol_groups layer
            pass
        elif node["type"] == "contacts":
            pass
        elif node["type"] == "mediaretry":
            # Not implemented
            pass
        elif node["type"] == "web":
            # Not implemented
            pass
        else:
            self.raiseErrorForNode(node)

        ack = OutgoingAckProtocolEntity(node["id"], "notification", node["type"], node["from"])
        self.toLower(ack.toProtocolTreeNode())
Exemplo n.º 5
0
 def onEncryptNotification(self, protocolTreeNode):
     entity = EncryptNotification.fromProtocolTreeNode(protocolTreeNode)
     ack = OutgoingAckProtocolEntity(protocolTreeNode["id"], "notification",
                                     protocolTreeNode["type"])
     self.toLower(ack.toProtocolTreeNode())
     self.sendKeys(fresh=False,
                   countPreKeys=self.__class__._COUNT_PREKEYS -
                   entity.getCount())
Exemplo n.º 6
0
 def onEncryptNotification(self, protocolTreeNode):
     entity = EncryptNotification.fromProtocolTreeNode(protocolTreeNode)
     ack = OutgoingAckProtocolEntity(protocolTreeNode["id"], "notification", protocolTreeNode["type"], protocolTreeNode["from"])
     self.toLower(ack.toProtocolTreeNode())
     self.flush_keys(
         self.manager.generate_signed_prekey(),
         self.manager.level_prekeys(force=True)
     )
Exemplo n.º 7
0
 def recvCall(self, node):
     entity = CallProtocolEntity.fromProtocolTreeNode(node)
     if entity.getType() == "offer":
         receipt = OutgoingReceiptProtocolEntity(node["id"], node["from"], callId = entity.getCallId())
         self.toLower(receipt.toProtocolTreeNode())
     else:
         ack = OutgoingAckProtocolEntity(node["id"], "call", None, node["from"])
         self.toLower(ack.toProtocolTreeNode())
     self.toUpper(entity)
Exemplo n.º 8
0
 def onIdentityChangeEncryptNotification(self, protocoltreenode):
     entity = IdentityChangeEncryptNotification.fromProtocolTreeNode(
         protocoltreenode)
     ack = OutgoingAckProtocolEntity(protocoltreenode["id"], "notification",
                                     protocoltreenode["type"],
                                     protocoltreenode["from"])
     self.toLower(ack.toProtocolTreeNode())
     self.getKeysFor([entity.getFrom(True)],
                     resultClbk=lambda _, __: None,
                     reason="identity")
Exemplo n.º 9
0
 def recvCall(self, node):
     entity = CallProtocolEntity.fromProtocolTreeNode(node)
     if entity.getType() == "offer":
         receipt = OutgoingReceiptProtocolEntity(node["id"],
                                                 node["from"],
                                                 callId=entity.getCallId())
         self.toLower(receipt.toProtocolTreeNode())
     else:
         ack = OutgoingAckProtocolEntity(node["id"], "call", None,
                                         node["from"])
         self.toLower(ack.toProtocolTreeNode())
     self.toUpper(entity)
Exemplo n.º 10
0
Arquivo: layer.py Projeto: be31/yowsup
    def recvNotification(self, node):
        if node["type"] == "picture":
            if node.getChild("set"):
                self.toUpper(PictureNotificationProtocolEntity.fromProtocolTreeNode(node))
            else:
                self.raiseErrorForNode(node)
        elif node["type"] == "status":
            self.toUpper(StatusNotificationProtocolEntity.fromProtocolTreeNode(node))
        elif node["type"] == "features":
            pass
        else:
            self.raiseErrorForNode(node)

        ack = OutgoingAckProtocolEntity(node["id"], "notification", node["type"])
        self.toLower(ack.toProtocolTreeNode())
Exemplo n.º 11
0
    def recvNotification(self, node):
        if node["type"] == "picture":
            if node.getChild("set"):
                self.toUpper(
                    PictureNotificationProtocolEntity.fromProtocolTreeNode(
                        node))
            else:
                self.raiseErrorForNode(node)
        elif node["type"] == "status":
            self.toUpper(
                StatusNotificationProtocolEntity.fromProtocolTreeNode(node))
        elif node["type"] == "features":
            pass
        else:
            self.raiseErrorForNode(node)

        ack = OutgoingAckProtocolEntity(node["id"], "notification",
                                        node["type"])
        self.toLower(ack.toProtocolTreeNode())
Exemplo n.º 12
0
    def recvNotification(self, node):
        if node["type"] == "picture":
            if node.getChild("set"):
                self.toUpper(SetPictureNotificationProtocolEntity.fromProtocolTreeNode(node))
            elif node.getChild("delete"):
                self.toUpper(DeletePictureNotificationProtocolEntity.fromProtocolTreeNode(node))
            else:
                self.raiseErrorForNode(node)
        elif node["type"] == "status":
            self.toUpper(StatusNotificationProtocolEntity.fromProtocolTreeNode(node))
        elif node["type"] in ["contacts", "subject", "w:gp2"]:
            # Implemented in respectively the protocol_contacts and protocol_groups layer
            pass
        else:
            logger.warn("Unsupported notification type: %s " % node["type"])
            logger.debug("Unsupported notification node: %s" % node)

        ack = OutgoingAckProtocolEntity(node["id"], "notification", node["type"], node["from"], participant=node["participant"])
        self.toLower(ack.toProtocolTreeNode())
Exemplo n.º 13
0
 def onEncryptNotification(self, protocolTreeNode):
     entity = EncryptNotification.fromProtocolTreeNode(protocolTreeNode)
     ack = OutgoingAckProtocolEntity(protocolTreeNode["id"], "notification", protocolTreeNode["type"], protocolTreeNode["from"])
     self.toLower(ack.toProtocolTreeNode())
     self.sendKeys(fresh=False, countPreKeys = self.__class__._COUNT_PREKEYS - entity.getCount())