Logo Search packages:      
Sourcecode: scenic version File versions  Download package

def scenic::application::Application::send_invite (   self )
Does the flight check. If OK, send an INVITE.

Definition at line 1070 of file application.py.

                         :
        """
        Does the flight check. If OK, send an INVITE.
        """
        self._is_negotiating = True
        contact = self.address_book.get_currently_selected_contact()
        if contact is None:
            dialogs.ErrorDialog.create(_("You must select a contact to invite."), parent=self.gui.main_window)
            return  # important
        else:
            ip = contact["address"]
            
        def _check_cb(result):
            #TODO: use the Deferred it will return
            if result is True:
                #self.prepare_before_rtp_stream()
                msg = {
                    "msg":"INVITE",
                    "protocol": self.protocol_version,
                    "sid":0, 
                    "please_send_to_port": self.config.negotiation_port, # FIXME: rename to listening_port
                    }
                msg.update(self._get_local_config_message_items())
                port = self.config.negotiation_port
                
                def _on_connected(proto):
                    self.client.send(msg)
                    return proto

                def _on_error(reason):
                    #FIXME: do we need this error dialog?
                    exc_type = type(reason.value)
                    if exc_type is error.ConnectionRefusedError:
                        msg = _("Could not invite contact %(name)s. \n\nScenic is not listening on port %(port)d of host %(ip)s.") % {"ip": ip, "name": contact["name"], "port": port}
                    elif exc_type is error.ConnectError:
                        msg = _("Could not invite contact %(name)s. \n\nHost %(ip)s is unreachable.") % {"ip": ip, "name": contact["name"]}
                    elif exc_type is error.NoRouteError:
                        msg = _("Could not invite contact %(name)s. \n\nHost %(ip)s is unreachable.") % {"ip": ip, "name": contact["name"]}
                    else:
                        msg = _("Could not invite contact %(name)s. \n\nError trying to connect to %(ip)s:%(port)s:\n %(reason)s") % {"ip": ip, "name": contact["name"], "port": port, "reason": reason.value}
                    log.error(msg.replace("\n", " "))
                    self.gui.hide_calling_dialog()
                    #if self._is_negotiating: # ???
                    self.gui.show_error_dialog(msg)
                    #    log.debug("Not showing an error since we were not negotiating.")
                    self._is_negotiating = False
                    return None
                   
                log.debug("sending %s to %s:%s" % (msg, ip, port))
                deferred = self.client.connect(ip, port)
                deferred.addCallback(_on_connected).addErrback(_on_error)
                self.gui.show_calling_dialog()
                # window will be hidden when we receive ACCEPT or REFUSE, or when we cancel
            else:
                log.error("Cannot send INVITE. Reason is : %s" % (result))
                self._is_negotiating = False

        check_deferred = self.check_if_ready_to_stream(role="offerer")
        check_deferred.addCallback(_check_cb)
   

Generated by  Doxygen 1.6.0   Back to index