main.py :  » Web-Services » Shtoom » shtoom-0.2 » shtoom » ui » qtui » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Web Services » Shtoom 
Shtoom » shtoom 0.2 » shtoom » ui » qtui » main.py
# Copyright (C) 2004 Anthony Baxter
from shtoommainwindow import ShtoomMainWindow

from shtoom.ui.base import ShtoomBaseUI

import sys
from twisted.python import log
from qt import *

class ShtoomMainWindow(ShtoomBaseWindow, ShtoomBaseUI):

    sending = False
    audiosource = None
    cookie = None
    def __init__(self, *args, **kwargs):
        ShtoomBaseWindow.__init__(self, *args, **kwargs)
        from shtoom.ui.logo import logoGif
        self.pixmapLogo.setPixmap(QPixmap(QByteArray(logoGif)))

    def debugMessage(self, message):
        log.msg(message)

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

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

    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())
        if not sipURL.startswith('sip:'):
            log.msg("Invalid SIP url %s"%(sipURL))
            return
        self.callButton.setEnabled(False)
        defer = self.app.placeCall(sipURL)
        defer.addCallbacks(self.callConnected, self.callFailed).addErrback(log.err)

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

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

    def callConnected(self, cookie):
        self.hangupButton.setEnabled(True)
        self.statusMessage('Call Connected')

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

    def setAudioSource(self, fn):
        self.audiosource = fn

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

    def clearButton_clicked(self):
        self.debuggingTextEdit.clear()

    def fileOpen(self):
        if self.audiosource:
            fn = self.audiosource
        else:
            fn = QString.null
        fn = QFileDialog.getOpenFileName(fn, QString.null, self)
        self.audiosource = str(fn)

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

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

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

    def incomingCall(self, description, call, defresp):
        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 = call
            self.callButton.setEnabled(False)
            defresp.callback('yes')
        else:
            # BOGUS
            defresp.errback(CallRejected)

    def dtmfButtonHash_pressed(self):
        if self.cookie is not None:
            self.app.startDTMF(self.cookie, '#')

    def dtmfButtonHash_released(self):
        if self.cookie is not None:
            self.app.stopDTMF(self.cookie, '#')

    def dtmfButtonStar_pressed(self):
        if self.cookie is not None:
            self.app.startDTMF(self.cookie, '*')

    def dtmfButtonStar_released(self):
        if self.cookie is not None:
            self.app.stopDTMF(self.cookie, '*')

    def dtmfButton1_pressed(self):
        if self.cookie is not None:
            self.app.startDTMF(self.cookie, '1')

    def dtmfButton1_released(self):
        if self.cookie is not None:
            self.app.stopDTMF(self.cookie, '1')

    def dtmfButton2_pressed(self):
        if self.cookie is not None:
            self.app.startDTMF(self.cookie, '2')

    def dtmfButton2_released(self):
        if self.cookie is not None:
            self.app.stopDTMF(self.cookie, '2')

    def dtmfButton3_pressed(self):
        if self.cookie is not None:
            self.app.startDTMF(self.cookie, '3')

    def dtmfButton3_released(self):
        if self.cookie is not None:
            self.app.stopDTMF(self.cookie, '3')

    def dtmfButton4_pressed(self):
        if self.cookie is not None:
            self.app.startDTMF(self.cookie, '4')

    def dtmfButton4_released(self):
        if self.cookie is not None:
            self.app.stopDTMF(self.cookie, '4')

    def dtmfButton5_pressed(self):
        if self.cookie is not None:
            self.app.startDTMF(self.cookie, '5')

    def dtmfButton5_released(self):
        if self.cookie is not None:
            self.app.stopDTMF(self.cookie, '5')

    def dtmfButton6_pressed(self):
        if self.cookie is not None:
            self.app.startDTMF(self.cookie, '6')

    def dtmfButton6_released(self):
        if self.cookie is not None:
            self.app.stopDTMF(self.cookie, '6')

    def dtmfButton7_pressed(self):
        if self.cookie is not None:
            self.app.startDTMF(self.cookie, '7')

    def dtmfButton7_released(self):
        if self.cookie is not None:
            self.app.stopDTMF(self.cookie, '7')

    def dtmfButton8_pressed(self):
        if self.cookie is not None:
            self.app.startDTMF(self.cookie, '8')

    def dtmfButton8_released(self):
        if self.cookie is not None:
            self.app.stopDTMF(self.cookie, '8')

    def dtmfButton9_pressed(self):
        if self.cookie is not None:
            self.app.startDTMF(self.cookie, '9')

    def dtmfButton9_released(self):
        if self.cookie is not None:
            self.app.stopDTMF(self.cookie, '9')

    def dtmfButton0_pressed(self):
        if self.cookie is not None:
            self.app.startDTMF(self.cookie, '0')

    def dtmfButton0_released(self):
        if self.cookie is not None:
            self.app.stopDTMF(self.cookie, '0')

class Logger:
    def __init__(self, textwidget):
        self._t = textwidget
    def flush(self):
        pass
    def write(self, text):
        self._t.append(text)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.