Exemple #1
0
    def _send_chunk(self, peer, peer_guid, chunk):
        logger.debug(">>> %s" % repr(chunk))

        msg = Message(self._client.profile)
        if chunk.version is 1 or peer_guid is None:
            msg.add_header('P2P-Dest', peer.account)
        elif chunk.version is 2:
            msg.add_header('P2P-Src', build_account(self._client.profile.account,
                                                    self._client.machine_guid))
            msg.add_header('P2P-Dest', build_account(peer.account, peer_guid))
        msg.content_type = 'application/x-msnmsgrp2p'
        msg.body = str(chunk) + struct.pack('>L', chunk.application_id)

        self._oustanding_sends += 1
        self._send_message(msg, MessageAcknowledgement.MSNC,
                (self._on_message_sent, peer, peer_guid, chunk),
                (self._on_message_error, peer, peer_guid, chunk))
Exemple #2
0
    def _send_chunk(self, peer, peer_guid, chunk):
        logger.debug(">>> %s" % repr(chunk))

        msg = Message(self._client.profile)
        if chunk.version is 1 or peer_guid is None:
            msg.add_header('P2P-Dest', peer.account)
        elif chunk.version is 2:
            msg.add_header(
                'P2P-Src',
                build_account(self._client.profile.account,
                              self._client.machine_guid))
            msg.add_header('P2P-Dest', build_account(peer.account, peer_guid))
        msg.content_type = 'application/x-msnmsgrp2p'
        msg.body = str(chunk) + struct.pack('>L', chunk.application_id)

        self._oustanding_sends += 1
        self._send_message(msg, MessageAcknowledgement.MSNC,
                           (self._on_message_sent, peer, peer_guid, chunk),
                           (self._on_message_error, peer, peer_guid, chunk))
Exemple #3
0
 def send_user_notification(self,
                            message,
                            contact,
                            contact_guid,
                            type,
                            callback=None,
                            errback=None):
     account = build_account(contact, contact_guid)
     arguments = (account, type)
     tr_id = self._send_command("UUN", arguments, message, True)
     self._callbacks[tr_id] = (callback, errback)
Exemple #4
0
 def _connect_cb(self, transport):
     self._state = ProtocolState.OPENING
     account = self._client.profile.account
     if self._client.protocol_version >= 16:
         account = build_account(self._client.profile.account, self._client.machine_guid)
     if self.__key is not None:
         arguments = (account, self.__key, self.__session_id)
         self._send_command("ANS", arguments)
     else:
         arguments = (account, self.__session_id)
         self._send_command("USR", arguments)
     self._state = ProtocolState.AUTHENTICATING
Exemple #5
0
 def _connect_cb(self, transport):
     self._state = ProtocolState.OPENING
     account = self._client.profile.account
     if self._client.protocol_version >= 16:
         account = build_account(self._client.profile.account,
                 self._client.machine_guid)
     if self.__key is not None:
         arguments = (account, self.__key, self.__session_id)
         self._send_command('ANS', arguments)
     else:
         arguments = (account, self.__session_id)
         self._send_command('USR', arguments)
     self._state = ProtocolState.AUTHENTICATING
Exemple #6
0
 def send_user_notification(self, message, contact, contact_guid, type,
         callback=None, errback=None):
     account = build_account(contact, contact_guid)
     arguments = (account, type)
     tr_id = self._send_command("UUN", arguments, message, True)
     self._callbacks[tr_id] = (callback, errback)
Exemple #7
0
 def remote_id(self):
     if self._version >= 2:
         return build_account(self._peer.account, self._peer_guid)
     return self._peer.account
Exemple #8
0
 def local_id(self):
     if self._version >= 2:
         return build_account(self._client.profile.account,
                 self._client.machine_guid)
     return self._client.profile.account