'If stream is authenticated than move items from "send" queue to "immidiatedly send" queue.
Else if the stream is failed then return all queued stanzas with error passed as argument.
Otherwise do nothing.'

def push_queue(self, failreason=ERR_RECIPIENT_UNAVAILABLE):

    if ((self._stream_state >= STREAM__CLOSED) or (self._socket_state >= SOCKET_DEAD)):
        self._owner.deactivatesession(self)
        for key in self.deliver_key_queue:
            self._dispatch(Error(self.deliver_queue_map[key], failreason), trusted=1)
        for stanza in self.stanza_queue:
            self._dispatch(Error(stanza, failreason), trusted=1)
        (self.deliver_queue_map, self.deliver_key_queue, self.stanza_queue) = ({}, [], [])
        return
    elif (self._session_state >= SESSION_AUTHED):
        for stanza in self.stanza_queue:
            txt = stanza.__str__().encode('utf-8')
            self.sendbuffer += txt
            self._stream_pos_queued += len(txt)
            self.deliver_queue_map[self._stream_pos_queued] = stanza
            self.deliver_key_queue.append(self._stream_pos_queued)
        self.stanza_queue = []
