Example #1
0
    def create_main_frame(self):

        mainBox = QVBoxLayout()
        self.phoneBox = QHBoxLayout()
        mainBox.addLayout(self.phoneBox)
        self.log_widget = LogWidget()
        mainBox.addWidget(self.log_widget)

        main_frame = QWidget()
        main_frame.setLayout(mainBox)
        main_frame.setMinimumWidth(300)

        self.setCentralWidget(main_frame)
Example #2
0
    def create_main_frame(self):

        mainBox = QVBoxLayout()
        self.phoneBox = QHBoxLayout()
        mainBox.addLayout(self.phoneBox)
        self.log_widget = LogWidget()
        mainBox.addWidget(self.log_widget)
       
        main_frame = QWidget()
        main_frame.setLayout(mainBox)
        main_frame.setMinimumWidth(300)
        
        self.setCentralWidget(main_frame)
Example #3
0
class SCCPClientWindow(QMainWindow):
    def __init__(self, reactor, parent=None):
        super(SCCPClientWindow, self).__init__(parent)
        self.phoneViews=[]
        self.reactor = reactor
        
        self.create_main_frame()
        self.createPhones()
        self.createIndicatorTimer()
        
 
    def create_main_frame(self):

        mainBox = QVBoxLayout()
        self.phoneBox = QHBoxLayout()
        mainBox.addLayout(self.phoneBox)
        self.log_widget = LogWidget()
        mainBox.addWidget(self.log_widget)
       
        main_frame = QWidget()
        main_frame.setLayout(mainBox)
        main_frame.setMinimumWidth(300)
        
        self.setCentralWidget(main_frame)
        
    def createPhones(self):
        self.createPhone(DEVICE_NAME1)
        self.createPhone(DEVICE_NAME2)
        self.createPhone(DEVICE_NAME3)
                
    def createPhone(self,deviceName):
        
        
        mainPhoneView = PhoneView(SERVER_HOST,deviceName,self.onConnect)
        self.phoneBox.addLayout(mainPhoneView)

        callActor = CallActor()
        actorView = ActorView(callActor)
        mainPhoneView.addLayout(actorView)

        sccpPhone = SCCPPhone(SERVER_HOST,deviceName)
        sccpPhone.setLogger(self.log)
        sccpPhone.setTimerProvider(self)
        callActor.setPhone(sccpPhone)
        callActor.setTimerProvider(self)
        sccpPhone.addCallHandler(callActor)
        
        mainPhoneView.useSccpPhone(sccpPhone)
        self.phoneViews.append(mainPhoneView)
        
        
    def createOneShotTimer(self,timerInSec,timerHandler):
        log.info('timer request sec : ' + `timerInSec`)
        oneTimer = QTimer(self)
        oneTimer.setSingleShot(True)
        oneTimer.timeout.connect(timerHandler)
        oneTimer.start(timerInSec*1000)

        
    def createIndicatorTimer(self):
        self.circle_timer = QTimer(self)
        self.circle_timer.timeout.connect(self.onIndicatorTimer)
        self.circle_timer.start(25)
        
    def onIndicatorTimer(self):
        for phoneView in self.phoneViews:
            phoneView.connectIndicator.next()
            
    def onConnect(self,serverHost,deviceName,networkClient):
        log.info("trying to connect to : "+serverHost+ " on " +`SERVER_PORT`)
        self.connection = self.reactor.connectTCP(serverHost, SERVER_PORT, networkClient)

    
    def createTimer(self,intervalSecs,timerCallback):
        self.keepalive_timer = QTimer(self)
        self.keepalive_timer.timeout.connect(timerCallback)
        self.keepalive_timer.start(intervalSecs*1000)
    
    def log(self, msg):
        timestamp = '[%010.3f]' % time.clock()
        self.log_widget.append(timestamp + ' ' + str(msg))

    def closeEvent(self, e):
        log.info("close event")
        self.reactor.stop()
Example #4
0
class SCCPClientWindow(QMainWindow):
    def __init__(self, reactor, parent=None):
        super(SCCPClientWindow, self).__init__(parent)
        self.phoneViews = []
        self.reactor = reactor

        self.create_main_frame()
        self.createPhones()
        self.createIndicatorTimer()

    def create_main_frame(self):

        mainBox = QVBoxLayout()
        self.phoneBox = QHBoxLayout()
        mainBox.addLayout(self.phoneBox)
        self.log_widget = LogWidget()
        mainBox.addWidget(self.log_widget)

        main_frame = QWidget()
        main_frame.setLayout(mainBox)
        main_frame.setMinimumWidth(300)

        self.setCentralWidget(main_frame)

    def createPhones(self):
        self.createPhone(config.DEVICE_NAME1)
        self.createPhone(config.DEVICE_NAME2)
        self.createPhone(config.DEVICE_NAME3)

    def createPhone(self, deviceName):
        mainPhoneView = PhoneView(config.SERVER_HOST, deviceName,
                                  self.onConnect)
        self.phoneBox.addLayout(mainPhoneView)

        callActor = CallActor()
        actorView = ActorView(callActor)
        mainPhoneView.addLayout(actorView)

        sccpPhone = SCCPPhone(config.SERVER_HOST, deviceName)
        sccpPhone.setLogger(self.log)
        sccpPhone.setTimerProvider(self)
        callActor.setPhone(sccpPhone)
        callActor.setTimerProvider(self)
        sccpPhone.addCallHandler(callActor)

        mainPhoneView.useSccpPhone(sccpPhone)
        self.phoneViews.append(mainPhoneView)

    def createOneShotTimer(self, timerInSec, timerHandler):
        self.log('timer request sec : ' + repr(timerInSec))
        oneTimer = QTimer(self)
        oneTimer.setSingleShot(True)
        oneTimer.timeout.connect(timerHandler)
        oneTimer.start(timerInSec * 1000)

    def createIndicatorTimer(self):
        self.circle_timer = QTimer(self)
        self.circle_timer.timeout.connect(self.onIndicatorTimer)
        self.circle_timer.start(25)

    def onIndicatorTimer(self):
        for phoneView in self.phoneViews:
            phoneView.connectIndicator.next()

    def onConnect(self, serverHost, deviceName, networkClient):
        self.log("trying to connect to : " + serverHost + " on " +
                 repr(config.SERVER_PORT))
        self.connection = self.reactor.connectTCP(serverHost,
                                                  config.SERVER_PORT,
                                                  networkClient)

    def createTimer(self, intervalSecs, timerCallback):
        self.keepalive_timer = QTimer(self)
        self.keepalive_timer.timeout.connect(timerCallback)
        self.keepalive_timer.start(intervalSecs * 1000)

    def log(self, msg):
        timestamp = '[%010.3f]' % time.clock()
        self.log_widget.append(timestamp + ' ' + str(msg))

    def closeEvent(self, e):
        self.log("close event")
        self.reactor.stop()