Commit b51e7fdd authored by Tijmen de Mes's avatar Tijmen de Mes

Replaced logging with message logging and added some log messages

parent 7288498c
...@@ -13,7 +13,6 @@ from PyQt5.QtWidgets import QApplication, QDialogButtonBox, QStyle, QDialog ...@@ -13,7 +13,6 @@ from PyQt5.QtWidgets import QApplication, QDialogButtonBox, QStyle, QDialog
from pgpy import PGPMessage from pgpy import PGPMessage
from pgpy.errors import PGPEncryptionError, PGPDecryptionError from pgpy.errors import PGPEncryptionError, PGPDecryptionError
from application import log
from application.notification import IObserver, NotificationCenter, NotificationData from application.notification import IObserver, NotificationCenter, NotificationData
from application.python import Null from application.python import Null
from application.system import makedirs from application.system import makedirs
...@@ -33,6 +32,7 @@ from sipsimple.streams.msrp.chat import CPIMPayload, CPIMParserError, CPIMNamesp ...@@ -33,6 +32,7 @@ from sipsimple.streams.msrp.chat import CPIMPayload, CPIMParserError, CPIMNamesp
from sipsimple.threading import run_in_thread from sipsimple.threading import run_in_thread
from sipsimple.util import ISOTimestamp from sipsimple.util import ISOTimestamp
from blink.logging import MessagingTrace as log
from blink.resources import Resources from blink.resources import Resources
from blink.sessions import SessionManager, StreamDescription, IncomingDialogBase from blink.sessions import SessionManager, StreamDescription, IncomingDialogBase
from blink.util import run_in_gui_thread from blink.util import run_in_gui_thread
...@@ -669,6 +669,7 @@ class MessageManager(object, metaclass=Singleton): ...@@ -669,6 +669,7 @@ class MessageManager(object, metaclass=Singleton):
if account is None: if account is None:
return return
log.info(f'Received a message for {account.id}')
data = notification.data data = notification.data
content_type = data.headers.get('Content-Type', Null).content_type content_type = data.headers.get('Content-Type', Null).content_type
...@@ -699,6 +700,8 @@ class MessageManager(object, metaclass=Singleton): ...@@ -699,6 +700,8 @@ class MessageManager(object, metaclass=Singleton):
encryption = self.check_encryption(content_type, body) encryption = self.check_encryption(content_type, body)
if encryption == 'OpenPGP': if encryption == 'OpenPGP':
log.info('Message is Open PGP encrypted')
if account.sms.enable_pgp and (account.sms.private_key is None or not os.path.exists(account.sms.private_key.normalized)): if account.sms.enable_pgp and (account.sms.private_key is None or not os.path.exists(account.sms.private_key.normalized)):
if not self.pgp_requests[account, GeneratePGPKeyRequest]: if not self.pgp_requests[account, GeneratePGPKeyRequest]:
generate_dialog = GeneratePGPKeyDialog() generate_dialog = GeneratePGPKeyDialog()
...@@ -708,10 +711,13 @@ class MessageManager(object, metaclass=Singleton): ...@@ -708,10 +711,13 @@ class MessageManager(object, metaclass=Singleton):
bisect.insort_right(self.pgp_requests, generate_request) bisect.insort_right(self.pgp_requests, generate_request)
generate_request.dialog.show() generate_request.dialog.show()
elif not account.sms.enable_pgp: elif not account.sms.enable_pgp:
log.info(f"-- Skipping PGP encrypted message, PGP is disabled for {account.id}")
return return
if content_type.lower() == 'text/pgp-private-key': if content_type.lower() == 'text/pgp-private-key':
log.info('Message is a private key')
if not account.sms.enable_pgp: if not account.sms.enable_pgp:
log.info(f"-- Skipping private key import, PGP is disabled for {account.id}")
return return
regex = "(?P<public_key>-----BEGIN PGP PUBLIC KEY BLOCK-----.*-----END PGP PUBLIC KEY BLOCK-----)" regex = "(?P<public_key>-----BEGIN PGP PUBLIC KEY BLOCK-----.*-----END PGP PUBLIC KEY BLOCK-----)"
matches = re.search(regex, body, re.DOTALL) matches = re.search(regex, body, re.DOTALL)
...@@ -732,7 +738,7 @@ class MessageManager(object, metaclass=Singleton): ...@@ -732,7 +738,7 @@ class MessageManager(object, metaclass=Singleton):
incoming_request.dialog.show() incoming_request.dialog.show()
if content_type.lower() == 'text/pgp-public-key': if content_type.lower() == 'text/pgp-public-key':
# print('-- Received public key') log.info('Message is a public key')
self._save_pgp_key(body, sender.uri) self._save_pgp_key(body, sender.uri)
from blink.contacts import URIUtils from blink.contacts import URIUtils
...@@ -748,10 +754,11 @@ class MessageManager(object, metaclass=Singleton): ...@@ -748,10 +754,11 @@ class MessageManager(object, metaclass=Singleton):
except StopIteration: except StopIteration:
blink_session = None blink_session = None
if content_type.lower() in self.__ignored_content_types__: if content_type.lower() in self.__ignored_content_types__:
print("Skipping session") log.debug(f"Not creating session for incoming message for content type {content.type.lower()}")
if content_type.lower() != IMDNDocument.content_type: if content_type.lower() != IMDNDocument.content_type:
return return
else: else:
log.debug("Starting new message session for incoming message")
blink_session = session_manager.create_session(contact, contact_uri, [StreamDescription('messages')], account=account, connect=False) blink_session = session_manager.create_session(contact, contact_uri, [StreamDescription('messages')], account=account, connect=False)
else: else:
if blink_session.fake_streams.get('messages') is None: if blink_session.fake_streams.get('messages') is None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment