Exemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     self._newCallURL = None
     self.dtmf = DTMF()
     self.dtmf.main = self
     self.debugging = Debugging()
     ShtoomBaseWindow.__init__(self, *args, **kwargs)
Exemplo n.º 2
0
 def __init__(self, *args, **kwargs):
     self._newCallURL = None
     self.dtmf = DTMF()
     self.dtmf.main = self
     self.debugging = Debugging()
     ShtoomBaseWindow.__init__(self, *args, **kwargs)
Exemplo n.º 3
0
class ShtoomMainWindow(ShtoomBaseWindow, ShtoomBaseUI):

    sending = False
    audiosource = None
    cookie = None
    _muted = False

    def __init__(self, *args, **kwargs):
        self._newCallURL = None
        self.dtmf = DTMF()
        self.dtmf.main = self
        self.debugging = Debugging()
        ShtoomBaseWindow.__init__(self, *args, **kwargs)

    def debugMessage(self, message):
        print message
        log.msg(message, system="ui")

    def statusMessage(self, message):
        self.statusLabel.setText(message)

    def errorMessage(self, message, exception=None):
        log.msg("%s: %s" % (_("ERROR"), message), system="ui")

    def hangupButton_clicked(self):
        self.app.dropCall(self.cookie)
        self.callButton.setEnabled(True)
        self.hangupButton.setEnabled(False)
        self.cookie = None

    def register_clicked(self):
        self.app.register()

    def callButton_clicked(self):
        sipURL = str(self.addressComboBox.currentText()).strip()
        if not sipURL:
            return
        self.addressComboBox.setCurrentText(sipURL)
        self.addressComboBox.insertItem(QString(sipURL))
        self._newCallURL = sipURL
        self.callButton.setEnabled(False)
        defer = self.app.placeCall(sipURL)
        defer.addCallbacks(self.callConnected, self.callFailed).addErrback(log.err)

    def callStarted(self, cookie):
        print "started", cookie
        self.cookie = cookie
        self.hangupButton.setEnabled(True)
        self.statusMessage(_("Calling..."))

    def callFailed(self, e, message=None):
        self.errorMessage("call failed", e.getErrorMessage())
        self.statusMessage(_("Call Failed"))
        self.hangupButton.setEnabled(False)
        self.callButton.setEnabled(True)
        self.cookie = None

    def callConnected(self, cookie):
        self.hangupButton.setEnabled(True)
        self.statusMessage(_("Call Connected"))
        if self._muted:
            self.app.muteCall(self.cookie)

    def callDisconnected(self, cookie, message):
        self.statusMessage("%s: %s" % (_("Call Disconnected"), message))
        self.hangupButton.setEnabled(False)
        self.callButton.setEnabled(True)
        self.cookie = None

    def getLogger(self):
        l = Logger(self.debugging.debuggingTextEdit)
        return l

    def editPreferences(self):
        from prefs import PreferencesDialog

        self.prefs = PreferencesDialog(self, self.app.getOptions())
        self.prefs.show()

    def preferences_save(self, options):
        self.app.updateOptions(options)
        self.prefs.hide()

    def preferences_discard(self):
        self.prefs.hide()

    def incomingCall(self, description, cookie):
        # XXX not good. Blockage. Argh.
        from twisted.internet import defer
        from shtoom.exceptions import CallRejected

        accept = QMessageBox.information(
            self, "Shtoom", "Incoming Call: %s\nAnswer?" % description, "Yes", "No", "", 0, 1
        )
        print "accept is", accept
        if accept == 0:
            self.cookie = cookie
            self.callButton.setEnabled(False)
            self.addressComboBox.setEnabled(False)
            return defer.succeed(cookie)
        else:
            return defer.fail(CallRejected(cookie))

    def muteCheck_stateChanged(self, val):
        if val:
            self._muted = True
        else:
            self._muted = False
        if self.cookie is not None:
            if val:
                self.app.muteCall(self.cookie)
            else:
                self.app.unmuteCall(self.cookie)

    def startDTMF(self, key):
        if self.cookie:
            self.app.startDTMF(self.cookie, key)

    def stopDTMF(self, key):
        if self.cookie:
            self.app.stopDTMF(self.cookie, key)

    def fileDTMF(self, *args):
        self.dtmf.show()

    def fileDebugging(self, *args):
        self.debugging.show()

    def _gotAuth(self, res):
        self._authdialog = None
        return res

    def getAuth(self, method, realm):
        # XXX tofix we should queue auth requests
        self._authdialog = AuthDialog()
        d = self._authdialog.getAuth(method, realm)
        d.addCallback(self._gotAuth)
        return d

    def __tr(self, str):
        return QString(_(str))

    def registerButton_clicked(self):
        self.app.register()

    def fileExit(self):
        from twisted.internet import reactor

        reactor.stop()

    def helpAbout(self):
        self.aboutDialog = AboutDialog()
        self.aboutDialog.show()
Exemplo n.º 4
0
class ShtoomMainWindow(ShtoomBaseWindow, ShtoomBaseUI):

    sending = False
    audiosource = None
    cookie = None
    _muted = False

    def __init__(self, *args, **kwargs):
        self._newCallURL = None
        self.dtmf = DTMF()
        self.dtmf.main = self
        self.debugging = Debugging()
        ShtoomBaseWindow.__init__(self, *args, **kwargs)

    def debugMessage(self, message):
        print message
        log.msg(message, system='ui')

    def statusMessage(self, message):
        self.statusLabel.setText(message)

    def errorMessage(self, message, exception=None):
        log.msg("%s: %s"%(_('ERROR'), message), system='ui')

    def hangupButton_clicked(self):
        self.app.dropCall(self.cookie)
        self.callButton.setEnabled(True)
        self.hangupButton.setEnabled(False)
        self.cookie = None

    def register_clicked(self):
        self.app.register()

    def callButton_clicked(self):
        sipURL = str(self.addressComboBox.currentText()).strip()
        if not sipURL:
            return
        self.addressComboBox.setCurrentText(sipURL)
        self.addressComboBox.insertItem(QString(sipURL))
        self._newCallURL = sipURL
        self.callButton.setEnabled(False)
        defer = self.app.placeCall(sipURL)
        defer.addCallbacks(self.callConnected, self.callFailed).addErrback(log.err)

    def callStarted(self, cookie):
        print "started", cookie
        self.cookie = cookie
        self.hangupButton.setEnabled(True)
        self.statusMessage(_('Calling...'))

    def callFailed(self, e, message=None):
        self.errorMessage("call failed", e.getErrorMessage())
        self.statusMessage(_('Call Failed'))
        self.hangupButton.setEnabled(False)
        self.callButton.setEnabled(True)
        self.cookie = None

    def callConnected(self, cookie):
        self.hangupButton.setEnabled(True)
        self.statusMessage(_('Call Connected'))
        if self._muted:
            self.app.muteCall(self.cookie)

    def callDisconnected(self, cookie, message):
        self.statusMessage('%s: %s'%(_('Call Disconnected'), message))
        self.hangupButton.setEnabled(False)
        self.callButton.setEnabled(True)
        self.cookie = None

    def getLogger(self):
        l = Logger(self.debugging.debuggingTextEdit)
        return l

    def editPreferences(self):
        from prefs import PreferencesDialog
        self.prefs =PreferencesDialog(self, self.app.getOptions())
        self.prefs.show()

    def preferences_save(self, options):
        self.app.updateOptions(options)
        self.prefs.hide()

    def preferences_discard(self):
        self.prefs.hide()

    def incomingCall(self, description, cookie):
        # XXX not good. Blockage. Argh.
        from twisted.internet import defer
        from shtoom.exceptions import CallRejected
        accept = QMessageBox.information(self, 'Shtoom',
                'Incoming Call: %s\nAnswer?'%description,
                'Yes', 'No', '', 0, 1)
        print "accept is", accept
        if accept == 0:
            self.cookie = cookie
            self.callButton.setEnabled(False)
            self.addressComboBox.setEnabled(False)
            return defer.succeed(cookie)
        else:
            return defer.fail(CallRejected(cookie))

    def muteCheck_stateChanged(self,val):
        if val:
            self._muted = True
        else:
            self._muted = False
        if self.cookie is not None:
            if val:
                self.app.muteCall(self.cookie)
            else:
                self.app.unmuteCall(self.cookie)

    def startDTMF(self, key):
        if self.cookie:
            self.app.startDTMF(self.cookie, key)

    def stopDTMF(self, key):
        if self.cookie:
            self.app.stopDTMF(self.cookie, key)

    def fileDTMF(self, *args):
        self.dtmf.show()

    def fileDebugging(self, *args):
        self.debugging.show()

    def _gotAuth(self, res):
        self._authdialog = None
        return res

    def getAuth(self, method, realm):
        # XXX tofix we should queue auth requests
        self._authdialog = AuthDialog()
        d = self._authdialog.getAuth(method, realm)
        d.addCallback(self._gotAuth)
        return d

    def __tr(self, str):
        return QString(_(str))

    def registerButton_clicked(self):
        self.app.register()

    def fileExit(self):
        from twisted.internet import reactor
        reactor.stop()

    def helpAbout(self):
        self.aboutDialog = AboutDialog()
        self.aboutDialog.show()