diff --git a/common/constants/view/pec/search_pec.py b/common/constants/view/pec/search_pec.py index 291cf8d..98965a2 100644 --- a/common/constants/view/pec/search_pec.py +++ b/common/constants/view/pec/search_pec.py @@ -27,6 +27,8 @@ PLACEHOLDER_PASSWORD="password" PLACEHOLDER_IMAP_SERVER="imap.server.com" PLACEHOLDER_IMAP_PORT="993" +PLACEHOLDER_SMPT_SERVER="smtp.server.com" +PLACEHOLDER_SMPT_PORT="456" PLACEHOLDER_TO="to@example.com" PLACEHOLDER_FROM="from@example.com" PLACEHOLDER_SUBJECT="Some subject" diff --git a/model/configurations/tabs/pec/pec.py b/model/configurations/tabs/pec/pec.py index 8774012..005087e 100644 --- a/model/configurations/tabs/pec/pec.py +++ b/model/configurations/tabs/pec/pec.py @@ -49,7 +49,7 @@ def set_default_values(self): self.imap_server = "" self.imap_port = "" self.retries = 5 - self.enabled = True + self.enabled = False self.db.session.add(self) self.db.session.commit() diff --git a/view/configuration.py b/view/configuration.py index 4d22a7d..de3229c 100644 --- a/view/configuration.py +++ b/view/configuration.py @@ -49,10 +49,10 @@ def retranslateUi(self): def load_tabs(self): package=view.configurations + class_names_modules = {} for importer, modname, ispkg in pkgutil.walk_packages(path=package.__path__, prefix=package.__name__+'.', onerror=lambda x: None): - - + #import module if not loaded if modname not in sys.modules and not ispkg: import_module(modname) @@ -64,9 +64,15 @@ def load_tabs(self): getattr(sys.modules[modname], '__is_tab__') and x.lower() == modname.rsplit( ".", 1 )[ 1 ]] if class_name: - tab = getattr(sys.modules[modname], class_name[0]) - tab = tab() - self.tabs.addTab(tab, tab.windowTitle()) + + class_names_modules.setdefault(class_name[0], []).append(sys.modules[modname]) + + ordered_keys = sorted(class_names_modules.keys()) + for key in ordered_keys: + for value in class_names_modules[key]: + tab = getattr(value, key) + tab = tab() + self.tabs.addTab(tab, tab.windowTitle()) def accept(self) -> None: for index in range(self.tabs.count()): diff --git a/view/configurations/tabs/pec/pec.py b/view/configurations/tabs/pec/pec.py index 43282c6..1acbdf8 100644 --- a/view/configurations/tabs/pec/pec.py +++ b/view/configurations/tabs/pec/pec.py @@ -16,7 +16,7 @@ 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 +from common.constants.view.pec import pec, search_pec __is_tab__ = True @@ -60,6 +60,7 @@ def initUI(self): self.horizontal_Layout_credential.addWidget(self.label_pec_email) self.pec_email = QtWidgets.QLineEdit(self.form_layout_widget_credential) self.pec_email.setEnabled(True) + self.pec_email.setPlaceholderText(search_pec.PLACEHOLDER_USERNAME) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -72,6 +73,7 @@ def initUI(self): self.horizontal_Layout_credential.addWidget(self.label_password) self.password = QtWidgets.QLineEdit(self.form_layout_widget_credential) self.password.setObjectName("password") + self.password.setPlaceholderText(search_pec.PLACEHOLDER_PASSWORD) self.password.setEchoMode(QtWidgets.QLineEdit.Password) self.horizontal_Layout_credential.addWidget(self.password) @@ -101,6 +103,7 @@ def initUI(self): self.imap_server = QtWidgets.QLineEdit(self.form_layout_widget_IMAP) self.imap_server.setEnabled(True) + self.imap_server.setPlaceholderText(search_pec.PLACEHOLDER_IMAP_SERVER) self.imap_server.setObjectName("imap_server") self.horizontal_layout_IMAP.addWidget(self.imap_server) @@ -108,6 +111,7 @@ def initUI(self): self.label_imap_port.setObjectName("label_imap_port") self.horizontal_layout_IMAP.addWidget(self.label_imap_port) self.imap_port = QtWidgets.QLineEdit(self.form_layout_widget_IMAP) + self.imap_port.setPlaceholderText(search_pec.PLACEHOLDER_IMAP_PORT) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -146,6 +150,7 @@ def initUI(self): self.horizontal_layout_SMTP.addWidget(self.label_smtp_server) self.smtp_server = QtWidgets.QLineEdit(self.form_layout_widget_SMTP) self.smtp_server.setEnabled(True) + self.smtp_server.setPlaceholderText(search_pec.PLACEHOLDER_SMPT_SERVER) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -158,6 +163,7 @@ def initUI(self): self.label_smtp_port.setObjectName("label_smtp_port") self.horizontal_layout_SMTP.addWidget(self.label_smtp_port) self.smtp_port = QtWidgets.QLineEdit(self.form_layout_widget_SMTP) + self.smtp_port.setPlaceholderText(search_pec.PLACEHOLDER_SMPT_PORT) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) diff --git a/view/post_acquisition/post.py b/view/post_acquisition/post.py index 16e0031..63f72cb 100644 --- a/view/post_acquisition/post.py +++ b/view/post_acquisition/post.py @@ -87,6 +87,8 @@ 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) + else: + self.is_finished_pec = True self.parent().upadate_progress_bar() self.is_finished_timestamp = True self.__async_task_are_finished() diff --git a/view/web/web.py b/view/web/web.py index a715983..082f31d 100644 --- a/view/web/web.py +++ b/view/web/web.py @@ -16,7 +16,7 @@ from PIL import Image from PyQt5 import QtCore, QtGui, QtWidgets -from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, QWebEngineDownloadItem +from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, QWebEngineDownloadItem, QWebEngineProfile from view.web.navigationtoolbar import NavigationToolBar as NavigationToolBarView from view.web.screenshot_select_area import SelectArea as SelectAreaView @@ -84,10 +84,10 @@ def __init__(self, *args, **kwargs): def init(self, case_info, wizard, options=None): + self.__init__() self.wizard = wizard self.case_info = case_info - self.configuration_view = ConfigurationView(self) self.configuration_view.hide() @@ -103,6 +103,7 @@ def init(self, case_info, wizard, options=None): self.setCentralWidget(self.tabs) + self.status = QtWidgets.QStatusBar() self.progress_bar = QtWidgets.QProgressBar() self.progress_bar.setMaximumWidth(400) @@ -124,7 +125,7 @@ def init(self, case_info, wizard, options=None): self.start_acquisition_is_started = False self.stop_acquisition_is_started = False - + self.__clear_cache() self.navtb = NavigationToolBarView(self) self.addToolBar(self.navtb) @@ -159,7 +160,6 @@ def init(self, case_info, wizard, options=None): # Get timestamp parameters self.configuration_timestamp = self.configuration_view.get_tab_from_name("configuration_timestamp") - self.add_new_tab(QtCore.QUrl(self.configuration_general.configuration['home_page_url']), 'Homepage') self.show() @@ -177,6 +177,9 @@ def init(self, case_info, wizard, options=None): def start_acquisition(self): + profile = QWebEngineProfile.defaultProfile() + profile.clearHttpCache() + self.acquisition_directory = self.case_view.form.controller.create_acquisition_directory( 'web', self.configuration_general.configuration['cases_folder_path'], @@ -281,11 +284,9 @@ def __stop_acquisition_is_finished(self): self.progress_bar.setHidden(True) self.status.showMessage('') - # delete cookies from the store and clean the cache - cookie_store = self.tabs.currentWidget().page().profile().cookieStore() - cookie_store.deleteAllCookies() - self.tabs.currentWidget().page().profile().clearAllVisitedLinks() - self.tabs.currentWidget().page().profile().clearHttpCache() + self.__clear_cache() + profile = QWebEngineProfile.defaultProfile() + profile.clearHttpCache() self.acquisition_is_running = False self.start_acquisition_is_finished = False @@ -553,6 +554,13 @@ def load_progress(self, progress): self.current_page_load_is_finished = True self.navtb.enable_screenshot_buttons() + def __clear_cache(self): + + profile = QWebEngineProfile.defaultProfile() + profile.clearAllVisitedLinks() + cookie_store = profile.cookieStore() + cookie_store.deleteAllCookies() + def __update_urlbar(self, q, browser=None): self.current_page_load_is_finished = False