Esempio n. 1
0
 def _upload_room_avatar_result(self, stanza):
     if not nbxmpp.isResultNode(stanza):
         reason = stanza.getErrorMsg() or stanza.getError()
         app.nec.push_incoming_event(
             InformationEvent(None,
                              dialog_name='avatar-upload-error',
                              args=reason))
Esempio n. 2
0
    def _add_local_ips_as_streamhosts_to_query(self, query, file_props):
        if not app.settings.get_account_setting(self._account,
                                                'ft_send_local_ips'):
            return

        my_ip = self._con.local_address
        if my_ip is None:
            log.warning('No local address available')
            return

        try:
            # The ip we're connected to server with
            my_ips = [my_ip]
            # all IPs from local DNS
            for addr in socket.getaddrinfo(socket.gethostname(), None):
                if (not addr[4][0] in my_ips
                        and not addr[4][0].startswith('127')
                        and not addr[4][0] == '::1'):
                    my_ips.append(addr[4][0])

            sender = file_props.sender
            port = app.settings.get('file_transfers_port')
            self._add_streamhosts_to_query(query, sender, port, my_ips)
        except socket.gaierror:
            from gajim.common.connection_handlers_events import InformationEvent
            app.nec.push_incoming_event(
                InformationEvent(None, dialog_name='wrong-host'))
Esempio n. 3
0
 def _del_privacy_list_result(stanza):
     if not nbxmpp.isResultNode(stanza):
         log.warning('List deletion failed: %s', stanza.getError())
         app.nec.push_incoming_event(
             InformationEvent(None,
                              dialog_name='privacy-list-error',
                              args=name))
     else:
         app.nec.push_incoming_event(
             PrivacyListRemovedEvent(None,
                                     conn=self._con,
                                     list_name=name))
Esempio n. 4
0
    def _add_local_ips_as_streamhosts_to_query(self, query, file_props):
        if not app.config.get_per('accounts', self._account, 'ft_send_local_ips'):
            return
        try:
            my_ips = [self._con.peerhost[0]] # The ip we're connected to server with
            # all IPs from local DNS
            for addr in socket.getaddrinfo(socket.gethostname(), None):
                if not addr[4][0] in my_ips and not addr[4][0].startswith('127') and not addr[4][0] == '::1':
                    my_ips.append(addr[4][0])

            sender = file_props.sender
            port = app.config.get('file_transfers_port')
            self._add_streamhosts_to_query(query, sender, port, my_ips)
        except socket.gaierror:
            from gajim.common.connection_handlers_events import InformationEvent
            app.nec.push_incoming_event(
                InformationEvent(None, dialog_name='wrong-host'))
Esempio n. 5
0
    def _muc_info_response(self, conn, stanza, callback):
        if not nbxmpp.isResultNode(stanza):
            error = stanza.getError()
            if error == 'item-not-found':
                # Groupchat does not exist
                log.info('MUC does not exist: %s', stanza.getFrom())
                callback()
            else:
                log.info('MUC disco error: %s', error)
                app.nec.push_incoming_event(
                    InformationEvent(
                        None, dialog_name='unable-join-groupchat', args=error))
            return

        log.info('MUC info received: %s', stanza.getFrom())
        muc_caps_cache.append(stanza)
        callback()
Esempio n. 6
0
    def wait_for_invite_response(self, msg):
        if msg.getTag('join', namespace=NS_GAMES):
            self.board = TicTacToeBoard(self, self.rows, self.cols)

            if self.role_s == 'x':
                self.our_turn()
            else:
                self.their_turn()

        elif msg.getTag('decline', namespace=NS_GAMES):
            app.nec.push_incoming_event(
                InformationEvent(
                    None,
                    conn=self.conn,
                    level='info',
                    pri_txt=_('Invitation refused'),
                    sec_txt=_('%(name)s refused your invitation to play tic '
                              'tac toe.') % {'name': self.name}))
            self.conn.delete_session(str(self.jid), self.thread_id)
Esempio n. 7
0
    def _muc_info_response(self, result, callback):
        if is_error_result(result):
            if result.type == 'item-not-found':
                # Groupchat does not exist
                self._log.info('MUC does not exist: %s', result.jid)
                callback()
            else:
                self._log.info('MUC disco error: %s', result)
                app.nec.push_incoming_event(
                    InformationEvent(
                        None,
                        dialog_name='unable-join-groupchat',
                        kwargs={
                            'server': result.jid,
                            'error': str(result)}))
            return

        self._log.info('MUC info received: %s', result.jid)
        muc_caps_cache.append(result)
        callback()
Esempio n. 8
0
 def make_bin_from_config(self, config_key, pipeline, text):
     pipeline = pipeline % app.config.get(config_key)
     try:
         gst_bin = Gst.parse_bin_from_description(pipeline, True)
         return gst_bin
     except GLib.GError as e:
         app.nec.push_incoming_event(
             InformationEvent(
                 None,
                 conn=self.session.connection,
                 level='error',
                 pri_txt=_('%s configuration error') % text.capitalize(),
                 sec_txt=_(
                     'Couldn’t set up %(text)s. Check your '
                     'configuration.\n\nPipeline was:\n%(pipeline)s\n\n'
                     'Error was:\n%(error)s') % {
                         'text': text,
                         'pipeline': pipeline,
                         'error': str(e)
                     }))
         raise JingleContentSetupException
Esempio n. 9
0
 def raise_information_event(dialog_name, args=None):
     app.nec.push_incoming_event(
         InformationEvent(None, dialog_name=dialog_name, args=args))
Esempio n. 10
0
    def _on_gst_message(self, bus, message):
        if message.type == Gst.MessageType.ELEMENT:
            name = message.get_structure().get_name()
            log.debug('gst element message: %s: %s', name, message)
            if name == 'farstream-new-active-candidate-pair':
                pass
            elif name == 'farstream-recv-codecs-changed':
                pass
            elif name == 'farstream-codecs-changed':
                if self.sent and self.p2psession.props.codecs_without_config:
                    self.send_description_info()
                    if self.transport.remote_candidates:
                        # those lines MUST be done after we get info on our
                        # codecs
                        self.p2pstream.add_remote_candidates(
                            self.transport.remote_candidates)
                        self.transport.remote_candidates = []
                        self.p2pstream.set_property(
                            'direction', Farstream.StreamDirection.BOTH)

            elif name == 'farstream-local-candidates-prepared':
                self.candidates_ready = True
                if self.is_ready():
                    self.session.on_session_state_changed(self)
            elif name == 'farstream-new-local-candidate':
                candidate = self.p2pstream.parse_new_local_candidate(
                    message)[1]
                self.transport.candidates.append(candidate)
                if self.sent:
                    # FIXME: Is this case even possible?
                    self.send_candidate(candidate)
            elif name == 'farstream-component-state-changed':
                state = message.get_structure().get_value('state')
                if state == Farstream.StreamState.FAILED:
                    reason = nbxmpp.Node('reason')
                    reason.setTag('failed-transport')
                    self.session.remove_content(self.creator, self.name,
                                                reason)
            elif name == 'farstream-error':
                log.error('Farstream error #%d!\nMessage: %s',
                          message.get_structure().get_value('error-no'),
                          message.get_structure().get_value('error-msg'))
        elif message.type == Gst.MessageType.ERROR:
            # TODO: Fix it to fallback to videotestsrc anytime an error occur,
            # or raise an error, Jingle way
            # or maybe one-sided stream?
            if not self.stream_failed_once:
                app.nec.push_incoming_event(
                    InformationEvent(
                        None,
                        dialog_name='gstreamer-error',
                        kwargs={
                            'error':
                            message.get_structure().get_value('gerror'),
                            'debug': message.get_structure().get_value('debug')
                        }))

            sink_pad = self.p2psession.get_property('sink-pad')

            # Remove old source
            self.src_bin.get_static_pad('src').unlink(sink_pad)
            self.src_bin.set_state(Gst.State.NULL)
            self.pipeline.remove(self.src_bin)

            if not self.stream_failed_once:
                # Add fallback source
                self.src_bin = self.get_fallback_src()
                self.pipeline.add(self.src_bin)
                self.src_bin.link(sink_pad)
                self.stream_failed_once = True
            else:
                reason = nbxmpp.Node('reason')
                reason.setTag('failed-application')
                self.session.remove_content(self.creator, self.name, reason)

            # Start playing again
            self.pipeline.set_state(Gst.State.PLAYING)
Esempio n. 11
0
 def _on_error(self, message):
     app.nec.push_incoming_event(
         InformationEvent(None, dialog_name='avahi-error', args=message))