forked from openlp/openlp
"Bugfix 1588369 - projectorNetwork signal/slot signature mismatch
- Fix projectorNetwork signal signature - Fix projector manager projectorNetwork signature and method call - Updated pjlink1 test - Merge 2.4 base and fix conflicts -------------------------------- lp:~alisonken1/openlp/bug-1588369-2.4-projectorNetwork-signal (revision 2639) [SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1636/ [SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1547/ [SUCCESS] https://ci.openlp.io..." bzr-revno: 2642 Fixes: https://launchpad.net/bugs/1588369
This commit is contained in:
commit
0e8ab10daf
@ -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
|
||||
@ -396,7 +396,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:
|
||||
@ -475,17 +475,15 @@ class PJLink1(QTcpSocket):
|
||||
log.warn('({ip}) send_command(): Not connected - returning'.format(ip=self.ip))
|
||||
self.send_queue = []
|
||||
return
|
||||
self.projectorNetwork.emit(S_NETWORK_SENDING)
|
||||
log.debug('({ip}) send_command(): Building cmd="{command}" opts="{data}"{salt}'.format(ip=self.ip,
|
||||
command=cmd,
|
||||
data=opts,
|
||||
salt='' if salt is None
|
||||
else ' with hash'))
|
||||
out = '{salt}{header}{command} {options}{suffix}'.format(salt="" if salt is None else salt,
|
||||
header=PJLINK_HEADER,
|
||||
command=cmd,
|
||||
options=opts,
|
||||
suffix=CR)
|
||||
self.projectorNetwork.emit(self.ip, S_NETWORK_SENDING)
|
||||
log.debug('(%s) send_command(): Building cmd="%s" opts="%s" %s' % (self.ip,
|
||||
cmd,
|
||||
opts,
|
||||
'' if salt is None else 'with hash'))
|
||||
if salt is None:
|
||||
out = '%s%s %s%s' % (PJLINK_HEADER, cmd, opts, CR)
|
||||
else:
|
||||
out = '%s%s%s %s%s' % (salt, PJLINK_HEADER, cmd, opts, CR)
|
||||
if out in self.send_queue:
|
||||
# Already there, so don't add
|
||||
log.debug('({ip}) send_command(out="{data}") Already in queue - skipping'.format(ip=self.ip,
|
||||
@ -535,13 +533,19 @@ class PJLink1(QTcpSocket):
|
||||
log.debug('({ip}) _send_string(): Sending "{data}"'.format(ip=self.ip, data=out.strip()))
|
||||
log.debug('({ip}) _send_string(): Queue = {data}'.format(ip=self.ip, data=self.send_queue))
|
||||
self.socket_timer.start()
|
||||
self.projectorNetwork.emit(S_NETWORK_SENDING)
|
||||
sent = self.write(out.encode('ascii'))
|
||||
self.waitForBytesWritten(2000) # 2 seconds should be enough
|
||||
if sent == -1:
|
||||
# Network error?
|
||||
self.change_status(E_NETWORK,
|
||||
translate('OpenLP.PJLink1', 'Error while sending data to projector'))
|
||||
try:
|
||||
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:
|
||||
# Network error?
|
||||
self.change_status(E_NETWORK,
|
||||
translate('OpenLP.PJLink1', 'Error while sending data to projector'))
|
||||
except SocketError as e:
|
||||
self.disconnect_from_host(abort=True)
|
||||
self.changeStatus(E_NETWORK,
|
||||
translate('OpenLP.PJLink1', '{code} : {string}').format(code=e.error(),
|
||||
string=e.errorString()))
|
||||
|
||||
def process_command(self, cmd, data):
|
||||
"""
|
||||
|
@ -61,6 +61,9 @@ 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 +291,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 +487,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 +725,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 +795,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 network busy icon')
|
||||
self.network_busy = False
|
||||
|
||||
@pyqtSlot(str, int, str)
|
||||
def update_status(self, ip, status=None, msg=None):
|
||||
"""
|
||||
|
@ -102,6 +102,20 @@ class TestPJLink(TestCase):
|
||||
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')
|
||||
|
||||
@patch.object(pjlink_test, 'change_status')
|
||||
def test_status_change(self, mock_change_status):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user