forked from openlp/openlp
Bugfix 1588369 - projectorNetwork signal/slot signature mismatch
This commit is contained in:
parent
2a1786ec00
commit
2dd4c87dde
@ -68,7 +68,7 @@ class PJLink1(QTcpSocket):
|
||||
"""
|
||||
# Signals sent by this module
|
||||
changeStatus = pyqtSignal(str, int, str)
|
||||
projectorNetwork = pyqtSignal(int) # Projector network activity
|
||||
projectorNetwork = pyqtSignal(str, int) # Projector network activity
|
||||
projectorStatus = pyqtSignal(int) # Status update
|
||||
projectorAuthentication = pyqtSignal(str) # Authentication error
|
||||
projectorNoAuthentication = pyqtSignal(str) # PIN set and no authentication needed
|
||||
@ -377,7 +377,7 @@ class PJLink1(QTcpSocket):
|
||||
self.projectorReceivedData.emit()
|
||||
return
|
||||
self.socket_timer.stop()
|
||||
self.projectorNetwork.emit(S_NETWORK_RECEIVED)
|
||||
self.projectorNetwork.emit(self.ip, S_NETWORK_RECEIVED)
|
||||
data_in = decode(read, 'ascii')
|
||||
data = data_in.strip()
|
||||
if len(data) < 7:
|
||||
@ -456,7 +456,7 @@ class PJLink1(QTcpSocket):
|
||||
log.warn('(%s) send_command(): Not connected - returning' % self.ip)
|
||||
self.send_queue = []
|
||||
return
|
||||
self.projectorNetwork.emit(S_NETWORK_SENDING)
|
||||
self.projectorNetwork.emit(self.ip, S_NETWORK_SENDING)
|
||||
log.debug('(%s) send_command(): Building cmd="%s" opts="%s" %s' % (self.ip,
|
||||
cmd,
|
||||
opts,
|
||||
@ -514,7 +514,7 @@ class PJLink1(QTcpSocket):
|
||||
log.debug('(%s) _send_string(): Queue = %s' % (self.ip, self.send_queue))
|
||||
self.socket_timer.start()
|
||||
try:
|
||||
self.projectorNetwork.emit(S_NETWORK_SENDING)
|
||||
self.projectorNetwork.emit(self.ip, S_NETWORK_SENDING)
|
||||
sent = self.write(out.encode('ascii'))
|
||||
self.waitForBytesWritten(2000) # 2 seconds should be enough
|
||||
if sent == -1:
|
||||
|
@ -61,6 +61,8 @@ STATUS_ICONS = {S_NOT_CONNECTED: ':/projector/projector_item_disconnect.png',
|
||||
E_NOT_CONNECTED: ':/projector/projector_not_connected_error.png'
|
||||
}
|
||||
|
||||
STATUS_NETWORK_BUSY = [S_CONNECTING, S_NETWORK_SENDING]
|
||||
STATUS_NETWORK_FREE = [E_NETWORK, E_UNKNOWN_SOCKET_ERROR, E_NOT_CONNECTED, S_NETWORK_RECEIVED]
|
||||
|
||||
class Ui_ProjectorManager(object):
|
||||
"""
|
||||
@ -288,6 +290,8 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
||||
self.projectordb = projectordb
|
||||
self.projector_list = []
|
||||
self.source_select_form = None
|
||||
self.network_list = {} # Currently active network communications keyed on IP
|
||||
self.network_busy = False
|
||||
|
||||
def bootstrap_initialise(self):
|
||||
"""
|
||||
@ -482,7 +486,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
||||
if ans == msg.Cancel:
|
||||
return
|
||||
try:
|
||||
projector.link.projectorNetwork.disconnect(self.update_status)
|
||||
projector.link.projectorNetwork.disconnect(self.update_network_status)
|
||||
except (AttributeError, TypeError):
|
||||
pass
|
||||
try:
|
||||
@ -720,7 +724,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
||||
thread.started.connect(item.link.thread_started)
|
||||
thread.finished.connect(item.link.thread_stopped)
|
||||
thread.finished.connect(thread.deleteLater)
|
||||
item.link.projectorNetwork.connect(self.update_status)
|
||||
item.link.projectorNetwork.connect(self.update_network_status)
|
||||
item.link.changeStatus.connect(self.update_status)
|
||||
item.link.projectorAuthentication.connect(self.authentication_error)
|
||||
item.link.projectorNoAuthentication.connect(self.no_authentication_error)
|
||||
@ -790,6 +794,39 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
||||
"""
|
||||
return self.projector_list
|
||||
|
||||
@pyqtSlot(str, int)
|
||||
def update_network_status(self, ip, status):
|
||||
"""
|
||||
Update network busy icon
|
||||
|
||||
NOTE: Placeholder for bugfix 1588369. Permanent fix will be in trunk for 2.6.
|
||||
|
||||
:param ip: IP of destination
|
||||
:param status: Status code
|
||||
"""
|
||||
log.debug('update_network_status(ip="%s" status=%d)' % (ip, status))
|
||||
# Keep track of what connections are currently being chatty
|
||||
if status in STATUS_NETWORK_BUSY:
|
||||
if ip not in self.network_list:
|
||||
log.debug('Adding %s to network list' % ip)
|
||||
self.network_list[ip] = status
|
||||
elif status in STATUS_NETWORK_FREE:
|
||||
if ip in self.network_list:
|
||||
log.debug('Removing %s from network list' % ip)
|
||||
self.network_list.pop(ip)
|
||||
else:
|
||||
log.warn('"%s" not in network list - something got dropped in setting?')
|
||||
else:
|
||||
log.warn('Unknown network status update: ip="%s" stutus: %s' % (ip, status))
|
||||
# Check for turnin on/off network busy icon
|
||||
if self.network_list:
|
||||
log.debug('network list: %s' % self.network_list)
|
||||
log.debug('Turning on network busy icon')
|
||||
self.network_busy = True
|
||||
else:
|
||||
log.debug('No network chatter - turning off netowkr icon')
|
||||
self.network_busy = False
|
||||
|
||||
@pyqtSlot(str, int, str)
|
||||
def update_status(self, ip, status=None, msg=None):
|
||||
"""
|
||||
|
@ -74,3 +74,17 @@ class TestPJLink(TestCase):
|
||||
# THEN: Projector class should be set with proper value
|
||||
self.assertEquals(pjlink.pjlink_class, '1',
|
||||
'Non-standard class reply should have set proper class')
|
||||
|
||||
def projector_class_test(self):
|
||||
"""
|
||||
Test class version from projector
|
||||
"""
|
||||
# GIVEN: Test object
|
||||
pjlink = pjlink_test
|
||||
|
||||
# WHEN: Process class response
|
||||
pjlink.process_clss('1')
|
||||
|
||||
# THEN: Projector class should be set to 1
|
||||
self.assertEquals(pjlink.pjlink_class, '1',
|
||||
'Projector should have returned class=1')
|
||||
|
Loading…
Reference in New Issue
Block a user