Exemplo n.º 1
0
    def _handle_UBX(self,command): # contact infos
        if not command.payload:
            return
        
        network_id = int(command.arguments[1])
        account = command.arguments[0] 

        contacts = self._client.address_book.contacts.\
                search_by_network_id(network_id).\
                search_by_account(account)

        if len(contacts) == 0:
            logger.warning("Contact (network_id=%d) %s not found" % \
                    (network_id, account))
        for contact in contacts:
            cm = ElementTree.fromstring(command.payload).find("./CurrentMedia")
            if cm is not None and cm.text is not None:
                parts = cm.text.split('\\0')
                if parts[1] == 'Music' and parts[2] == '1':
                    cm = (parts[4].encode("utf-8"), parts[5].encode("utf-8"))
                    contact._server_property_changed("current-media", cm)
                    continue
                elif parts[2] == '0':
                    contact._server_property_changed("current-media", None)
            else:
                contact._server_property_changed("current-media", None)
            pm = ElementTree.fromstring(command.payload).find("./PSM")
            if pm is not None and pm.text is not None:
                pm = pm.text.encode("utf-8")
            else:
                pm = ""
            contact._server_property_changed("personal-message", pm)
Exemplo n.º 2
0
    def _handle_NOT(self, command):
        notification_xml = xml_utils.unescape(command.payload)
        notification = ElementTree.fromstring(notification_xml)

        service = notification.findtext('MSG/BODY/NotificationData/Service')
        if service != 'ABCHInternal':
            return

        try:
            notification_id = notification.attrib['id']
            site_id = notification.attrib['siteid']
            message_id = notification.find('MSG').attrib['id']
            send_device = notification.find('TO/VIA').attrib['agent']
            receiver_cid = notification.findtext('MSG/BODY/NotificationData/CID')
            receiver_account = notification.find('TO').attrib['name'].lower()

            if notification_id != '0' or site_id != '45705' \
            or message_id != '0' or send_device != 'messenger' \
            or receiver_cid != str(self._client.profile.cid)  \
            or receiver_account != self._client.profile.account.lower():
                return

        except KeyError:
            return

        self._client.address_book.sync(True)
Exemplo n.º 3
0
    def _handle_NOT(self, command):
        notification_xml = xml_utils.unescape(command.payload)
        notification = ElementTree.fromstring(notification_xml)

        service = notification.findtext("MSG/BODY/NotificationData/Service")
        if service != "ABCHInternal":
            return

        try:
            notification_id = notification.attrib["id"]
            site_id = notification.attrib["siteid"]
            message_id = notification.find("MSG").attrib["id"]
            send_device = notification.find("TO/VIA").attrib["agent"]
            receiver_cid = notification.findtext("MSG/BODY/NotificationData/CID")
            receiver_account = notification.find("TO").attrib["name"].lower()

            if (
                notification_id != "0"
                or site_id != "45705"
                or message_id != "0"
                or send_device != "messenger"
                or receiver_cid != str(self._client.profile.cid)
                or receiver_account != self._client.profile.account.lower()
            ):
                return

        except KeyError:
            return

        self._client.address_book.sync(True)
Exemplo n.º 4
0
    def _handle_NOT(self, command):
        notification_xml = xml_utils.unescape(command.payload)
        notification = ElementTree.fromstring(notification_xml)

        service = notification.findtext('MSG/BODY/NotificationData/Service')
        if service != 'ABCHInternal':
            return

        try:
            notification_id = notification.attrib['id']
            site_id = notification.attrib['siteid']
            message_id = notification.find('MSG').attrib['id']
            send_device = notification.find('TO/VIA').attrib['agent']
            receiver_cid = notification.findtext(
                'MSG/BODY/NotificationData/CID')
            receiver_account = notification.find('TO').attrib['name'].lower()

            if notification_id != '0' or site_id != '45705' \
            or message_id != '0' or send_device != 'messenger' \
            or receiver_cid != str(self._client.profile.cid)  \
            or receiver_account != self._client.profile.account.lower():
                return

        except KeyError:
            return

        self._client.address_book.sync(True)
Exemplo n.º 5
0
    def _handle_xml(self, blob):
        blob.data.seek(10, 0)
        data = blob.data.read()
        datastr = str(data).replace("\000", "")
        message = unicode(data, "utf-16-le").rstrip("\x00")
        tree = ElementTree.fromstring(datastr)
        ips = []
        ports = []
        for node in tree.findall("tcp/*"):
            if node.tag == "tcpport":
                ports.append(int(node.text))
            elif node.tag.startswith("tcpipaddress"):
                ips.append(node.text)
        rid = tree.find("rid").text
        self._session_id = int(tree.find("session").text)

        self._remote_candidates = []
        for ip in ips:
            for port in ports:
                candidate = (ip, port, rid)
                self._remote_candidates.append(candidate)

        # Signalling is done, now pass it off to the handler to control it further
        print "Received xml %s" % message
        self._dispatch("on_webcam_viewer_data_received", self._session_id, rid, self._remote_candidates)
        if self._producer:
            self.send_binary_viewer_data()
        elif self._local_candidates is not None:
            self._send_xml()
        else:
            self._xml_needed = True
Exemplo n.º 6
0
 def _parse(self, body):
     tree = ElementTree.fromstring(body)
     self._id = int(tree.find("session").text)
     desc = self._create_stream_description(None)
     self.descriptions.append(desc)
     for node in tree.findall("tcp/*"):
         if node.tag == "tcpport":
             desc.ports.append(int(node.text))
         elif node.tag.startswith("tcpipaddress"):
             desc.ips.append(node.text)
     desc.rid = tree.find("rid").text
     return self._descriptions
Exemplo n.º 7
0
 def _parse(self, body):
     tree = ElementTree.fromstring(body)
     self._id = int(tree.find("session").text)
     desc = self._create_stream_description(None)
     self.descriptions.append(desc)
     for node in tree.findall("tcp/*"):
         if node.tag == "tcpport":
             desc.ports.append(int(node.text))
         elif node.tag.startswith("tcpipaddress"):
             desc.ips.append(node.text)
     desc.rid = tree.find("rid").text
     return self._descriptions
Exemplo n.º 8
0
    def _handle_UBX(self, command):  # contact infos
        if not command.payload:
            return
        idx, network_id, account = self.__parse_network_and_account(command)

        try:
            tree = ElementTree.fromstring(command.payload)
        except:
            logger.error("Invalid XML data in received UBX command")
            return

        utl = self.__find_node(tree, "./UserTileLocation", "")
        cm_parts = self.__find_node(tree, "./CurrentMedia", "").split('\\0')
        pm = self.__find_node(tree, "./PSM", "")
        rmu = self.__find_node(tree, "./RMU", "")
        ss = self.__find_node(tree, "./SignatureSound", None)
        mg = self.__find_node(tree, "./MachineGuid", "{}").lower()[1:-1]

        msn_object = None
        if utl != "" and utl != "0":
            msn_object = papyon.p2p.MSNObject.parse(self._client, utl)

        cm = None
        if len(cm_parts
               ) >= 6 and cm_parts[1] == 'Music' and cm_parts[2] == '1':
            cm = (cm_parts[4], cm_parts[5])

        eps = tree.findall("./EndpointData")
        end_points = {}
        for ep in eps:
            guid = uuid.UUID(ep.get("id"))
            caps = self.__find_node(ep, "Capabilities", "0:0")
            end_points[guid] = profile.EndPoint(guid, caps)
        peps = tree.findall("./PrivateEndpointData")
        for pep in peps:
            guid = uuid.UUID(pep.get("id"))
            if guid not in end_points: continue
            end_point = end_points[guid]
            end_point.name = self.__find_node(pep, "EpName", "")
            end_point.idle = bool(
                self.__find_node(pep, "Idle", "").lower() == "true")
            end_point.client_type = int(self.__find_node(pep, "ClientType", 0))
            end_point.state = self.__find_node(pep, "State", "")

        contact = self.__search_account(account, network_id)
        if contact is not None:
            contact._add_flag(profile.ContactFlag.EXTENDED_PRESENCE_KNOWN)
            contact._server_property_changed("end-points", end_points)
            contact._server_property_changed("msn-object", msn_object)
            contact._server_property_changed("current-media", cm)
            contact._server_property_changed("personal-message", pm)
            contact._server_property_changed("signature-sound", ss)
Exemplo n.º 9
0
    def _handle_UBX(self, command): # contact infos
        if not command.payload:
            return
        print command.payload
        idx, network_id, account = self.__parse_network_and_account(command)

        try:
            tree = ElementTree.fromstring(command.payload)
        except:
            logger.error("Invalid XML data in received UBX command")
            return

        utl = self.__find_node(tree, "./UserTileLocation", "")
        cm_parts = self.__find_node(tree, "./CurrentMedia", "").split('\\0')
        pm = self.__find_node(tree, "./PSM", "")
        rmu = self.__find_node(tree, "./RMU", "")
        ss = self.__find_node(tree, "./SignatureSound", None)
        mg = self.__find_node(tree, "./MachineGuid", "{}").lower()[1:-1]

        msn_object = None
        if utl != "" and utl != "0":
            msn_object = papyon.p2p.MSNObject.parse(self._client, utl)

        cm = None
        if len(cm_parts) >= 6 and cm_parts[1] == 'Music' and cm_parts[2] == '1':
            cm = (cm_parts[4], cm_parts[5])

        eps = tree.findall("./EndpointData")
        end_points = {}
        for ep in eps:
            guid = uuid.UUID(ep.get("id"))
            caps = self.__find_node(ep, "Capabilities", "0:0")
            end_points[guid] = profile.EndPoint(guid, caps)
        peps = tree.findall("./PrivateEndpointData")
        for pep in peps:
            guid = uuid.UUID(pep.get("id"))
            if guid not in end_points: continue
            end_point = end_points[guid]
            end_point.name = self.__find_node(pep, "EpName", "")
            end_point.idle = bool(self.__find_node(pep, "Idle", "").lower() == "true")
            end_point.client_type = int(self.__find_node(pep, "ClientType", 0))
            end_point.state = self.__find_node(pep, "State", "")

        contact = self.__search_account(account, network_id)
        if contact is not None:
            contact._add_flag(profile.ContactFlag.EXTENDED_PRESENCE_KNOWN)
            contact._server_property_changed("end-points", end_points)
            contact._server_property_changed("msn-object", msn_object)
            contact._server_property_changed("current-media", cm)
            contact._server_property_changed("personal-message", pm)
            contact._server_property_changed("signature-sound", ss)
Exemplo n.º 10
0
    def _handle_UBX(self,command): # contact infos
        if not command.payload:
            return

        idx, network_id, account = self._parse_account(command)

        try:
            tree = ElementTree.fromstring(command.payload)
        except:
            logger.error("Invalid XML data in received UBX command")
            return

        cm = tree.find("./CurrentMedia")
        if cm is not None and cm.text is not None:
            parts = cm.text.split('\\0')
            if parts[1] == 'Music' and parts[2] == '1':
                cm = (parts[4].encode("utf-8"), parts[5].encode("utf-8"))
            elif parts[2] == '0':
                cm = None
        else:
            cm = None

        pm = tree.find("./PSM")
        if pm is not None and pm.text is not None:
            pm = pm.text.encode("utf-8")
        else:
            pm = ""

        ss = tree.find("./SignatureSound")
        if ss is not None and ss.text is not None:
            ss = ss.text.encode("utf-8")
        else:
            ss = None

        contacts = self._client.address_book.contacts.\
                search_by_network_id(network_id).\
                search_by_account(account)

        if len(contacts) == 0:
            logger.warning("Contact (network_id=%d) %s not found" % \
                    (network_id, account))

        for contact in contacts:
            contact._server_property_changed("current-media", cm)
            contact._server_property_changed("personal-message", pm)
            contact._server_property_changed("signature-sound", ss)
Exemplo n.º 11
0
    def _handle_UBX(self, command):  # contact infos
        if not command.payload:
            return

        idx, network_id, account = self._parse_account(command)

        try:
            tree = ElementTree.fromstring(command.payload)
        except:
            logger.error("Invalid XML data in received UBX command")
            return

        cm = tree.find("./CurrentMedia")
        if cm is not None and cm.text is not None:
            parts = cm.text.split('\\0')
            if parts[1] == 'Music' and parts[2] == '1':
                cm = (parts[4].encode("utf-8"), parts[5].encode("utf-8"))
            elif parts[2] == '0':
                cm = None
        else:
            cm = None

        pm = tree.find("./PSM")
        if pm is not None and pm.text is not None:
            pm = pm.text.encode("utf-8")
        else:
            pm = ""

        ss = tree.find("./SignatureSound")
        if ss is not None and ss.text is not None:
            ss = ss.text.encode("utf-8")
        else:
            ss = None

        contacts = self._client.address_book.contacts.\
                search_by_network_id(network_id).\
                search_by_account(account)

        if len(contacts) == 0:
            logger.warning("Contact (network_id=%d) %s not found" % \
                    (network_id, account))

        for contact in contacts:
            contact._server_property_changed("current-media", cm)
            contact._server_property_changed("personal-message", pm)
            contact._server_property_changed("signature-sound", ss)