49
49
from PyQt5.QtCore import pyqtSignal, pyqtSlot
50
50
from PyQt5.QtNetwork import QAbstractSocket, QTcpSocket
52
from openlp.core.common import translate, qmd5_hash
52
from openlp.core.common import translate, md5_hash
53
53
from openlp.core.lib.projector.constants import *
297
297
Processes the initial connection and authentication (if needed).
298
298
Starts poll timer if connection is established.
300
NOTE: Qt md5 hash function doesn't work with projector authentication. Use the python md5 hash function.
300
302
:param data: Optional data if called from another routine
302
304
log.debug('({ip}) check_login(data="{data}")'.format(ip=self.ip, data=data))
345
347
elif data_check[1] == '0' and self.pin is not None:
346
348
# Pin set and no authentication needed
349
log.warning('({ip}) Regular connection but PIN set'.format(ip=self.name))
347
350
self.disconnect_from_host()
348
351
self.change_status(E_AUTHENTICATION)
349
log.debug('({ip}) emitting projectorNoAuthentication() signal'.format(ip=self.name))
352
log.debug('({ip}) Emitting projectorNoAuthentication() signal'.format(ip=self.name))
350
353
self.projectorNoAuthentication.emit(self.name)
352
355
elif data_check[1] == '1':
353
356
# Authenticated login with salt
354
log.debug('({ip}) Setting hash with salt="{data}"'.format(ip=self.ip, data=data_check[2]))
355
log.debug('({ip}) pin="{data}"'.format(ip=self.ip, data=self.pin))
356
salt = qmd5_hash(salt=data_check[2].encode('ascii'), data=self.pin.encode('ascii'))
358
log.warning('({ip}) Authenticated connection but no pin set'.format(ip=self.name))
359
self.disconnect_from_host()
360
self.change_status(E_AUTHENTICATION)
361
log.debug('({ip}) Emitting projectorAuthentication() signal'.format(ip=self.name))
362
self.projectorAuthentication.emit(self.name)
365
log.debug('({ip}) Setting hash with salt="{data}"'.format(ip=self.ip, data=data_check[2]))
366
log.debug('({ip}) pin="{data}"'.format(ip=self.ip, data=self.pin))
367
salt = md5_hash(salt=data_check[2].encode('ascii'), data=self.pin.encode('ascii'))
359
370
# We're connected at this point, so go ahead and do regular I/O