Skip to content

Commit

Permalink
Merge pull request #33 from fit-project/hotfix/small-fixes
Browse files Browse the repository at this point in the history
Hotfix/small fixes
  • Loading branch information
zitelog authored May 15, 2023
2 parents 176f793 + c4cd575 commit c649278
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 59 deletions.
Binary file added assets/images/green-mark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/red-mark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions common/constants/view/pec/pec.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@
DOWNLOAD_EML_SUCCESS="EML file has been successfully downloaded."
RETRIES_NUMBER="Retries EML download"
SERVER_CONFIGURATION="Server configuration"
VERIFY_IMAP="Verify IMAP server"
VERIFY_SMTP="Verify SMTP server"




94 changes: 88 additions & 6 deletions view/configurations/tabs/pec/pec.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
# Copyright (c) 2023 FIT-Project
# SPDX-License-Identifier: GPL-3.0-only
# -----
######
######
import imaplib
import smtplib

from PyQt5 import QtCore, QtWidgets
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QMessageBox, QLabel, QSizePolicy

from common.constants import error
from controller.configurations.tabs.pec.pec import Pec as PecController
from view.error import Error as ErrorView
from common.constants.view.pec import pec

__is_tab__ = True
Expand Down Expand Up @@ -82,7 +89,7 @@ def initUI(self):
self.group_box_server.setObjectName("group_box_server")

self.form_layout_widget_IMAP = QtWidgets.QWidget(self.group_box_server)
self.form_layout_widget_IMAP.setGeometry(QtCore.QRect(10, 20, 511, 24))
self.form_layout_widget_IMAP.setGeometry(QtCore.QRect(10, 20, 600, 24))
self.form_layout_widget_IMAP.setObjectName("form_layout_widget_server_IMAP")
self.horizontal_layout_IMAP = QtWidgets.QHBoxLayout(self.form_layout_widget_IMAP)
self.horizontal_layout_IMAP.setContentsMargins(0, 0, 0, 0)
Expand Down Expand Up @@ -110,8 +117,23 @@ def initUI(self):
self.horizontal_layout_IMAP.addWidget(self.imap_port)


self.verification_imap_button = QtWidgets.QPushButton(self.form_layout_widget_IMAP)
self.verification_imap_button.clicked.connect(self.__verify_imap)
self.verification_imap_button.setObjectName("verification_imap_button")
self.verification_imap_button.setEnabled(True)
self.horizontal_layout_IMAP.addWidget(self.verification_imap_button)

self.info_imap_img = QLabel(self)
self.info_imap_img.setEnabled(True)
self.info_imap_img.setPixmap(QPixmap("assets/images/red-mark.png").scaled(20, 20))
self.info_imap_img.setScaledContents(True)
self.info_imap_img.setGeometry(QtCore.QRect(630, 192, 20, 20))
self.info_imap_img.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.info_imap_img.setVisible(False)


self.form_layout_widget_SMTP = QtWidgets.QWidget(self.group_box_server)
self.form_layout_widget_SMTP.setGeometry(QtCore.QRect(10, 50, 511, 24))
self.form_layout_widget_SMTP.setGeometry(QtCore.QRect(10, 50, 600, 24))
self.form_layout_widget_SMTP.setObjectName("form_layout_widget_SMTP")

self.horizontal_layout_SMTP = QtWidgets.QHBoxLayout(self.form_layout_widget_SMTP)
Expand Down Expand Up @@ -143,11 +165,26 @@ def initUI(self):
self.smtp_port.setSizePolicy(sizePolicy)
self.smtp_port.setObjectName("smtp_port")
self.horizontal_layout_SMTP.addWidget(self.smtp_port)


self.verification_smtp_button = QtWidgets.QPushButton(self.form_layout_widget_SMTP)
self.verification_smtp_button.clicked.connect(self.__verify_smtp)
self.verification_smtp_button.setObjectName("verification_smtp_button")
self.verification_smtp_button.setEnabled(True)
self.horizontal_layout_SMTP.addWidget(self.verification_smtp_button)

self.info_smtp_img = QLabel(self)
self.info_smtp_img.setEnabled(True)
self.info_smtp_img.setPixmap(QPixmap("assets/images/red-mark.png").scaled(20, 20))
self.info_smtp_img.setScaledContents(True)
self.info_smtp_img.setGeometry(QtCore.QRect(630, 222, 20, 20))
self.info_smtp_img.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.info_smtp_img.setVisible(False)



def retranslateUi(self):
self.setWindowTitle(pec.WINDOW_TITLE)
self.enabled_checkbox.setText(pec.ENABLE)
self.enabled_checkbox.setText(pec.ENABLE)
self.group_box_credential.setTitle(pec.CREDENTIAL_CONFIGURATION)
self.label_pec_email.setText(pec.LABEL_EMAIL)
self.label_password.setText(pec.LABEL_PASSWORD)
Expand All @@ -157,7 +194,9 @@ def retranslateUi(self):
self.label_imap_port.setText(pec.LABEL_IMAP_PORT)
self.label_smtp_server.setText(pec.LABEL_SMPT_SERVER)
self.label_smtp_port.setText(pec.LABEL_SMPT_PORT)

self.verification_imap_button.setText(pec.VERIFY_IMAP)
self.verification_smtp_button.setText(pec.VERIFY_SMTP)

def __is_enabled_pec(self):
self.group_box_credential.setEnabled(self.enabled_checkbox.isChecked())
self.group_box_retries.setEnabled(self.enabled_checkbox.isChecked())
Expand Down Expand Up @@ -190,7 +229,50 @@ def __get_current_values(self):

self.options[keyword] = value

def __verify_imap(self):
try:
self.info_imap_img.setVisible(False)
server = imaplib.IMAP4_SSL(self.imap_server.text(), int(self.imap_port.text()))
server.login(self.pec_email.text(), self.password.text())
server.logout()
self.info_imap_img.setPixmap(QPixmap("assets/images/green-mark.png").scaled(20, 20))
self.info_imap_img.setVisible(True)

except Exception as e:
self.info_imap_img.setPixmap(QPixmap("assets/images/red-mark.png").scaled(20, 20))
self.info_imap_img.setVisible(True)
error_dlg = ErrorView(QMessageBox.Critical,
pec.LOGIN_FAILED,
error.LOGIN_ERROR,
str(e)
)
error_dlg.exec_()


def __verify_smtp(self):
try:
self.info_smtp_img.setVisible(False)
server = smtplib.SMTP_SSL(self.smtp_server.text(), int(self.smtp_port.text()))
server.login(self.pec_email.text(), self.password.text())
server.quit()
self.info_smtp_img.setPixmap(QPixmap("assets/images/green-mark.png").scaled(20, 20))
self.info_smtp_img.setVisible(True)


except Exception as e:

self.info_smtp_img.setPixmap(QPixmap("assets/images/red-mark.png").scaled(20, 20))
self.info_smtp_img.setVisible(True)

error_dlg = ErrorView(QMessageBox.Critical,
pec.LOGIN_FAILED,
error.LOGIN_ERROR,
str(e)
)
error_dlg.exec_()

def accept(self) -> None:

self.__get_current_values()
self.controller.options = self.options

Expand Down
6 changes: 0 additions & 6 deletions view/instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ def init(self, case_info, wizard, options=None):
self.case_action.triggered.connect(self.__case)
self.menuBar().addAction(self.case_action)

# BACK TO WIZARD
back_action = QtWidgets.QAction("Back to wizard", self)
back_action.setStatusTip("Go back to the main menu")
back_action.triggered.connect(self.__back_to_wizard)
self.menuBar().addAction(back_action)

self.configuration_general = self.configuration_view.get_tab_from_name("configuration_general")

Expand Down Expand Up @@ -507,6 +502,5 @@ def __back_to_wizard(self):
self.wizard.show()

def closeEvent(self, event):
print("CLOSE")
event.ignore()
self.__back_to_wizard()
17 changes: 8 additions & 9 deletions view/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,6 @@ def init(self, case_info, wizard, options=None):
self.case_action.triggered.connect(self.__case)
self.menuBar().addAction(self.case_action)

# BACK ACTION
back_action = QtWidgets.QAction("Back to wizard", self)
back_action.setStatusTip("Go back to the main menu")
back_action.triggered.connect(self.__back_to_wizard)
self.menuBar().addAction(back_action)

self.configuration_general = self.configuration_view.get_tab_from_name("configuration_general")


Expand Down Expand Up @@ -702,6 +696,11 @@ def __configuration(self):
self.configuration_view.exec_()

def __back_to_wizard(self):
self.deleteLater()
self.wizard.reload_case_info()
self.wizard.show()
if self.is_acquisition_running is False:
self.deleteLater()
self.wizard.reload_case_info()
self.wizard.show()

def closeEvent(self, event):
event.ignore()
self.__back_to_wizard()
30 changes: 16 additions & 14 deletions view/post_acquisition/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def __init__(self, parent: None):
def execute(self, folder, case_info, type):
self.calculate_acquisition_file_hash(folder)
self.generate_pdf_report(folder, case_info, type)
self.generate_timestamp_report(folder)
self.send_report_from_pec(folder, case_info, type)
self.generate_timestamp_report(folder, case_info, type)


def calculate_acquisition_file_hash(self, folder):

Expand Down Expand Up @@ -66,7 +66,7 @@ def generate_pdf_report(self, folder, case_info,type):
report.generate_pdf(type, self.parent().get_time())
self.parent().upadate_progress_bar()

def generate_timestamp_report(self, folder):
def generate_timestamp_report(self, folder, case_info, type):
self.parent().set_message_on_the_statusbar(tasks.TIMESTAMP)
options = TimestampController().options
if options['enabled']:
Expand All @@ -79,11 +79,14 @@ def generate_timestamp_report(self, folder):
timestamp.finished.connect(timestamp.deleteLater)
timestamp.finished.connect(self.thread_timestamp.quit)

self.thread_timestamp.finished.connect(self.__thread_timestamp_is_finished)
self.thread_timestamp.finished.connect(lambda:self.__thread_timestamp_is_finished(folder, case_info, type))

self.thread_timestamp.start()

def __thread_timestamp_is_finished(self):
def __thread_timestamp_is_finished(self,folder, case_info, type):
options = PecController().options
if options['enabled']:
self.send_report_from_pec(folder, case_info, type)
self.parent().upadate_progress_bar()
self.is_finished_timestamp = True
self.__async_task_are_finished()
Expand All @@ -92,15 +95,14 @@ def send_report_from_pec(self, folder, case_info, type):

self.parent().set_message_on_the_statusbar(tasks.PEC)

options = PecController().options
if options['enabled']:
self.pec = PecView(self)
self.pec.sentpec.connect(lambda status: self.__is_pec_sent(status))
self.pec.downloadedeml.connect(lambda status: self.__is_eml_downloaded(status))
view_form=True
self.pec.init(case_info, type, folder, view_form)
if view_form is False:
self.pec.send()
self.pec = PecView(self)
self.pec.sentpec.connect(lambda status: self.__is_pec_sent(status))
self.pec.downloadedeml.connect(lambda status: self.__is_eml_downloaded(status))
view_form = False
self.pec.init(case_info, type, folder, view_form)
if view_form is False:
self.pec.send()


def __is_pec_sent(self, status):
if status == Status.SUCCESS:
Expand Down
10 changes: 4 additions & 6 deletions view/verify_pdf_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ def init(self, case_info, wizard, options=None):
self.case_action.triggered.connect(self.case)
self.menuBar().addAction(self.case_action)

# BACK ACTION
back_action = QtWidgets.QAction("Back to wizard", self)
back_action.setStatusTip("Go back to the main menu")
back_action.triggered.connect(self.__back_to_wizard)
self.menuBar().addAction(back_action)

# set font
font = QtGui.QFont()
font.setPointSize(10)
Expand Down Expand Up @@ -322,3 +316,7 @@ def __back_to_wizard(self):
self.deleteLater()
self.wizard.reload_case_info()
self.wizard.show()

def closeEvent(self, event):
event.ignore()
self.__back_to_wizard()
10 changes: 4 additions & 6 deletions view/verify_pec.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ def init(self, case_info, wizard, options=None):
self.case_action.triggered.connect(self.__case)
self.menuBar().addAction(self.case_action)

# BACK ACTION
back_action = QtWidgets.QAction("Back to wizard", self)
back_action.setStatusTip("Go back to the main menu")
back_action.triggered.connect(self.__back_to_wizard)
self.menuBar().addAction(back_action)

self.eml_group_box = QtWidgets.QGroupBox(self.centralwidget)
self.eml_group_box.setEnabled(True)
self.eml_group_box.setGeometry(QtCore.QRect(50, 20, 500, 180))
Expand Down Expand Up @@ -172,3 +166,7 @@ def __back_to_wizard(self):
self.deleteLater()
self.wizard.reload_case_info()
self.wizard.show()

def closeEvent(self, event):
event.ignore()
self.__back_to_wizard()
21 changes: 9 additions & 12 deletions view/web/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, *args, **kwargs):
self.case_info = None
self.__tasks = []

self.setWindowFlag(QtCore.Qt.WindowMinMaxButtonsHint, False)
self.setWindowFlag(QtCore.Qt.WindowMinMaxButtonsHint, True)
self.setObjectName('FITWeb')

def init(self, case_info, wizard, options=None):
Expand Down Expand Up @@ -150,11 +150,6 @@ def init(self, case_info, wizard, options=None):
case_action.triggered.connect(self.case)
self.menuBar().addAction(case_action)

# BACK ACTION
back_action = QtWidgets.QAction("Back to wizard", self)
back_action.setStatusTip("Go back to the main menu")
back_action.triggered.connect(self.__back_to_wizard)
self.menuBar().addAction(back_action)

self.configuration_general = self.configuration_view.get_tab_from_name("configuration_general")

Expand Down Expand Up @@ -509,16 +504,16 @@ def add_new_tab(self, qurl=None, label="Blank"):

self.browser.loadFinished.connect(lambda _, i=i, browser=self.browser:
self.__page_on_loaded(i, browser))



if i == 0:
self.showMaximized()


def __page_on_loaded(self, tab_index, browser):
self.tabs.setTabText(tab_index, browser.page().title())

self.current_page_load_is_finished = True
self.navtb.enable_screenshot_buttons()

def tab_open_doubleclick(self, i):
if i == -1 and self.isEnabled(): # No tab under the click
self.add_new_tab()
Expand Down Expand Up @@ -553,11 +548,13 @@ def navigate_to_url(self): # Does not receive the Url

self.tabs.currentWidget().setUrl(q)

def load_progress(self, prog):
pass
def load_progress(self, progress):
if progress == 100:
self.current_page_load_is_finished = True
self.navtb.enable_screenshot_buttons()

def __update_urlbar(self, q, browser=None):

def __update_urlbar(self, q, browser=None):
self.current_page_load_is_finished = False
self.navtb.enable_screenshot_buttons()

Expand Down

0 comments on commit c649278

Please sign in to comment.