Exemplo n.º 1
0
 def _on_finished(self, new_device, password):
     save_device_with_password(config_dir=self.config.config_dir,
                               device=new_device,
                               password=password)
     show_info(self, _("TEXT_CLAIM_DEVICE_SUCCESSFUL"))
     self.status = (new_device, password)
     self.dialog.accept()
    def on_share_clicked(self):
        user_name = self.line_edit_share.text()
        if not user_name:
            return
        if user_name == self.core.device.user_id:
            show_info(self,
                      _("TEXT_WORKSPACE_SHARING_CANNOT_SHARE_WITH_YOURSELF"))
            return
        for i in range(self.scroll_content.layout().count()):
            item = self.scroll_content.layout().itemAt(i)
            if item and item.widget() and item.widget().user == user_name:
                show_info(
                    self,
                    _("TEXT_WORKSPACE_SHARING_ALREADY_SHARED_user").format(
                        user=user_name))
                return

        self.jobs_ctx.submit_job(
            ThreadSafeQtSignal(self, "share_success", QtToTrioJob),
            ThreadSafeQtSignal(self, "share_error", QtToTrioJob),
            _do_share_workspace,
            user_fs=self.user_fs,
            workspace_fs=self.workspace_fs,
            user=user_name,
            role=_index_to_role(self.combo_role.currentIndex()),
        )
Exemplo n.º 3
0
    def _on_invite_user_success(self, job):
        assert job.is_finished()
        assert job.status == "ok"

        email = job.ret
        show_info(self, _("TEXT_USER_INVITE_SUCCESS_email").format(email=email))
        self.reset()
Exemplo n.º 4
0
 async def _on_validate_clicked(self):
     self.button_validate.setEnabled(False)
     auth_method = self.widget_auth.get_auth_method()
     try:
         if auth_method == DeviceFileType.PASSWORD:
             save_device_with_password_in_config(
                 self.core.config.config_dir, self.loaded_device,
                 self.widget_auth.get_auth())
         elif auth_method == DeviceFileType.SMARTCARD:
             await save_device_with_smartcard_in_config(
                 self.core.config.config_dir, self.loaded_device)
         show_info(self, _("TEXT_AUTH_CHANGE_SUCCESS"))
         if self.dialog:
             self.dialog.accept()
         elif QApplication.activeModalWidget():
             QApplication.activeModalWidget().accept()
         else:
             logger.warning(
                 "Cannot close dialog when changing password info")
     except LocalDeviceCryptoError as exc:
         self.button_validate.setEnabled(True)
         if auth_method == DeviceFileType.SMARTCARD:
             show_error(self, _("TEXT_INVALID_SMARTCARD"), exception=exc)
     except LocalDeviceNotFoundError as exc:
         self.button_validate.setEnabled(True)
         if auth_method == DeviceFileType.PASSWORD:
             show_error(self, _("TEXT_CANNOT_SAVE_DEVICE"), exception=exc)
     except LocalDeviceError as exc:
         self.button_validate.setEnabled(True)
         show_error(self, _("TEXT_CANNOT_SAVE_DEVICE"), exception=exc)
Exemplo n.º 5
0
 def on_get_file_path_clicked(self):
     files = self.table_files.selected_files()
     if len(files) != 1:
         return
     path = self.current_directory / files[0].name
     addr = self.jobs_ctx.run_sync(self.workspace_fs.generate_file_link,
                                   path)
     desktop.copy_to_clipboard(addr.to_url())
     show_info(self, _("TEXT_FILE_LINK_COPIED_TO_CLIPBOARD"))
Exemplo n.º 6
0
 def _on_finished() -> None:
     nonlocal widget
     # It's safe to access the widget status here since this does not perform a Qt call.
     # But the underlying C++ widget might already be deleted so we should make sure not
     # not do anything Qt related with this widget.
     if not widget.status:
         return
     show_info(self, _("TEXT_ENROLLMENT_QUERY_SUCCEEDED"))
     self.reload_login_devices()
Exemplo n.º 7
0
 def save(self):
     self.event_bus.send(
         "gui.config.changed",
         telemetry_enabled=self.check_box_send_data.isChecked(),
         gui_tray_enabled=self.check_box_tray.isChecked(),
         gui_language=self.combo_languages.currentData(),
         gui_check_version_at_startup=self.check_box_check_at_startup.isChecked(),
         gui_workspace_color=self.check_box_workspace_color.isChecked(),
     )
     show_info(self, _("TEXT_SETTINGS_NEED_RESTART"))
 def on_registration_success(self):
     assert self.registration_job.is_finished()
     assert self.registration_job.status == "ok"
     show_info(self, _("TEXT_INVITE_USER_SUCCESS"))
     self.registration_job = None
     if self.dialog:
         self.dialog.accept()
     elif QApplication.activeModalWidget():
         QApplication.activeModalWidget().accept()
     else:
         logger.warning("Cannot close dialog when inviting user")
Exemplo n.º 9
0
 def button_reencrypt_clicked(self):
     if self.reencryption_needs:
         if not self.is_owner:
             show_info(self.parent(),
                       message=_("TEXT_WORKSPACE_ONLY_OWNER_CAN_REENCRYPT"))
             return
         self.reencrypt_clicked.emit(
             self.workspace_id,
             bool(self.reencryption_needs.user_revoked),
             bool(self.reencryption_needs.role_revoked),
         )
Exemplo n.º 10
0
 def on_get_file_path_clicked(self):
     files = self.table_files.selected_files()
     if len(files) != 1:
         return
     url = BackendOrganizationFileLinkAddr.build(
         self.core.device.organization_addr,
         self.workspace_fs.workspace_id,
         self.current_directory / files[0].name,
     )
     desktop.copy_to_clipboard(str(url))
     show_info(self, _("TEXT_FILE_LINK_COPIED_TO_CLIPBOARD"))
    def _on_share_update_success(self, job):
        workspace_name, successes, errors = job.ret

        if errors:
            show_error(
                self,
                _("TEXT_WORKSPACE_SHARING_UPDATE_ROLES_ERROR_errors".format(
                    errors="\n".join(errors.keys()))),
            )
        else:
            show_info(self, _("TEXT_WORKSPACE_SHARING_UPDATE_ROLES_SUCCESS"))
            self.reset()
Exemplo n.º 12
0
    def switch_to_login_tab(
        self, file_link_addr: Optional[BackendOrganizationFileLinkAddr] = None
    ) -> None:
        # Retrieve the login tab
        idx = self._get_login_tab_index()
        if idx != -1:
            self.switch_to_tab(idx)
        else:
            # No loging tab, create one
            tab = self.add_new_tab()
            tab.show_login_widget()
            self.on_tab_state_changed(tab, "login")
            idx = self.tab_center.count() - 1
            self.switch_to_tab(idx)

        if not file_link_addr:
            # We're done here
            return

        # Find the device corresponding to the organization in the link
        for available_device in list_available_devices(self.config.config_dir):
            if available_device.organization_id == file_link_addr.organization_id:
                break

        else:
            # Cannot reach this organization with our available devices
            show_error(
                self,
                _("TEXT_FILE_LINK_NOT_IN_ORG_organization").format(
                    organization=file_link_addr.organization_id
                ),
            )
            return

        # Pre-select the corresponding device
        login_w = self.tab_center.widget(idx).get_login_widget()
        login_w._on_account_clicked(available_device)

        # Set the path
        instance_widget = self.tab_center.widget(idx)
        instance_widget.set_workspace_path(file_link_addr)

        # Prompt the user for the need to log in first
        show_info(
            self,
            _("TEXT_FILE_LINK_PLEASE_LOG_IN_organization").format(
                organization=file_link_addr.organization_id
            ),
        )
Exemplo n.º 13
0
    def on_claim_success(self):
        assert self.claim_user_job
        assert self.claim_user_job.is_finished()
        assert self.claim_user_job.status == "ok"

        self.status = self.claim_user_job.ret
        self.claim_user_job = None
        show_info(parent=self,
                  message=_("TEXT_CLAIM_USER_SUCCESS"),
                  button_text=_("ACTION_CONTINUE"))
        if self.dialog:
            self.dialog.accept()
        elif QApplication.activeModalWidget():
            QApplication.activeModalWidget().accept()
        else:
            logger.warning("Cannot close dialog when claiming user")
Exemplo n.º 14
0
    def save(self):
        if platform.system(
        ) == "Windows" and win_registry.is_acrobat_reader_dc_present():
            win_registry.set_acrobat_app_container_enabled(
                not self.check_acrobat_container.isChecked())

        self.event_bus.send(
            "gui.config.changed",
            telemetry_enabled=self.check_box_send_data.isChecked(),
            gui_tray_enabled=self.check_box_tray.isChecked(),
            gui_language=self.combo_languages.currentData(),
            gui_check_version_at_startup=self.check_box_check_at_startup.
            isChecked(),
            gui_workspace_color=self.check_box_workspace_color.isChecked(),
        )
        show_info(self, _("TEXT_SETTINGS_NEED_RESTART"))
Exemplo n.º 15
0
    def _on_revoke_success(self, job):
        assert job.is_finished()
        assert job.status == "ok"

        user_info = job.ret
        show_info(
            self,
            _("TEXT_USER_REVOKE_SUCCESS_user").format(
                user=user_info.short_user_display))
        for i in range(self.layout_users.count()):
            item = self.layout_users.itemAt(i)
            if item:
                button = item.widget()
                if (button and isinstance(button, UserButton)
                        and button.user_info.user_id == user_info.user_id):
                    button.user_info = user_info
 async def _on_validate_clicked(self):
     if isinstance(self.current_page, DeviceRecoveryImportPage1Widget):
         # No try/except given `self.line_edit_device` has already been validated against `DeviceLabel`
         device_label = DeviceLabel(
             validators.trim_user_name(
                 self.current_page.line_edit_device.text()))
         self.jobs_ctx.submit_job(
             self.create_new_device_success,
             self.create_new_device_failure,
             self._create_new_device,
             device_label=device_label,
             file_path=PurePath(self.current_page.get_recovery_key_file()),
             passphrase=self.current_page.get_passphrase(),
         )
     else:
         try:
             self.button_validate.setEnabled(False)
             auth_method = self.current_page.get_auth_method()
             if auth_method == DeviceFileType.PASSWORD:
                 save_device_with_password_in_config(
                     config_dir=self.config.config_dir,
                     device=self.new_device,
                     password=self.current_page.get_auth(),
                 )
             else:
                 await save_device_with_smartcard_in_config(
                     config_dir=self.config.config_dir,
                     device=self.new_device)
             show_info(self, translate("TEXT_RECOVERY_IMPORT_SUCCESS"))
             self.dialog.accept()
         except LocalDeviceCryptoError as exc:
             self.button_validate.setEnabled(True)
             if auth_method == DeviceFileType.SMARTCARD:
                 show_error(self,
                            translate("TEXT_INVALID_SMARTCARD"),
                            exception=exc)
         except LocalDeviceNotFoundError as exc:
             if auth_method == DeviceFileType.PASSWORD:
                 show_error(self,
                            translate("TEXT_CANNOT_SAVE_DEVICE"),
                            exception=exc)
             self.button_validate.setEnabled(True)
         except LocalDeviceError as exc:
             show_error(self,
                        translate("TEXT_CANNOT_SAVE_DEVICE"),
                        exception=exc)
             self.button_validate.setEnabled(True)
Exemplo n.º 17
0
 def change_password(self):
     if self.line_edit_password.text() != self.line_edit_password_check.text():
         show_error(self, _("TEXT_CHANGE_PASSWORD_PASSWORD_MISMATCH"))
     else:
         key_file = get_key_file(self.core.config.config_dir, self.core.device)
         try:
             change_device_password(
                 key_file, self.line_edit_old_password.text(), self.line_edit_password.text()
             )
             show_info(self, _("TEXT_CHANGE_PASSWORD_SUCCESS"))
             if self.dialog:
                 self.dialog.accept()
             elif QApplication.activeModalWidget():
                 QApplication.activeModalWidget().accept()
             else:
                 logger.warning("Cannot close dialog when changing password info")
         except LocalDeviceCryptoError as exc:
             show_error(self, _("TEXT_CHANGE_PASSWORD_INVALID_PASSWORD"), exception=exc)
Exemplo n.º 18
0
    def on_bootstrap_success(self):
        assert self.bootstrap_job
        assert self.bootstrap_job.is_finished()
        assert self.bootstrap_job.status == "ok"

        self.button_bootstrap.setDisabled(False)
        self.status = self.bootstrap_job.ret
        self.bootstrap_job = None
        self.check_infos()
        show_info(
            parent=self, message=_("TEXT_BOOTSTRAP_ORG_SUCCESS"), button_text=_("ACTION_CONTINUE")
        )
        if self.dialog:
            self.dialog.accept()
        elif QApplication.activeModalWidget():
            QApplication.activeModalWidget().accept()
        else:
            logger.warning("Cannot close dialog when bootstraping")
Exemplo n.º 19
0
    def go_to_file_link(self, action_addr):
        found_org = self._find_device_from_addr(action_addr,
                                                display_error=True) is not None
        if not found_org:
            self.switch_to_login_tab()
            return

        for idx in range(self.tab_center.count()):
            if self.tab_center.tabText(idx) == _(
                    "TEXT_TAB_TITLE_LOG_IN_SCREEN"):
                continue
            w = self.tab_center.widget(idx)
            if (not w or not w.core
                    or w.core.device.organization_addr.organization_id !=
                    action_addr.organization_id):
                continue
            user_manifest = w.core.user_fs.get_user_manifest()
            found_workspace = False
            for wk in user_manifest.workspaces:
                if not wk.role:
                    continue
                if wk.id == action_addr.workspace_id:
                    found_workspace = True
                    central_widget = w.get_central_widget()
                    try:
                        central_widget.go_to_file_link(wk.id, action_addr.path)
                        self.switch_to_tab(idx)
                    except AttributeError:
                        logger.exception("Central widget is not available")
                    return
            if not found_workspace:
                show_error(
                    self,
                    _("TEXT_FILE_LINK_WORKSPACE_NOT_FOUND_organization").
                    format(organization=action_addr.organization_id),
                )
                return
        show_info(
            self,
            _("TEXT_FILE_LINK_PLEASE_LOG_IN_organization").format(
                organization=action_addr.organization_id),
        )
        self.switch_to_login_tab(action_addr)
Exemplo n.º 20
0
    def _on_req_success(self):
        assert self.create_job
        assert self.create_job.is_finished()
        assert self.create_job.status == "ok"

        self.status = self.create_job.ret
        self.create_job = None
        show_info(
            parent=self,
            message=_("TEXT_BOOTSTRAP_ORG_SUCCESS_organization").format(
                organization=self.status[0].organization_id),
            button_text=_("ACTION_CONTINUE"),
        )
        if self.dialog:
            self.dialog.accept()
        elif QApplication.activeModalWidget():
            QApplication.activeModalWidget().accept()
        else:
            logger.warning("Cannot close dialog when org wizard")
Exemplo n.º 21
0
    def _on_sharing_updated(self, event, new_entry, previous_entry):
        if new_entry is None or new_entry.role is None:
            # Sharing revoked
            show_error(
                self,
                _("TEXT_FILE_SHARING_REVOKED_workspace").format(
                    workspace=previous_entry.name))
            self.back_clicked.emit()

        elif previous_entry is not None and previous_entry.role is not None:
            self.current_user_role = new_entry.role
            self.label_role.setText(
                get_role_translation(self.current_user_role))
            if (previous_entry.role != WorkspaceRole.READER
                    and new_entry.role == WorkspaceRole.READER):
                show_info(
                    self,
                    _("TEXT_FILE_SHARING_DEMOTED_TO_READER_workspace").format(
                        workspace=previous_entry.name),
                )
Exemplo n.º 22
0
 async def _on_finished(self, new_device, auth_method, password):
     try:
         if auth_method == DeviceFileType.PASSWORD:
             save_device_with_password_in_config(
                 config_dir=self.config.config_dir,
                 device=new_device,
                 password=password)
         elif auth_method == DeviceFileType.SMARTCARD:
             await save_device_with_smartcard_in_config(
                 config_dir=self.config.config_dir, device=new_device)
         show_info(self, _("TEXT_CLAIM_DEVICE_SUCCESSFUL"))
         self.status = (new_device, auth_method, password)
         self.dialog.accept()
     except LocalDeviceCryptoError as exc:
         if auth_method == DeviceFileType.SMARTCARD:
             show_error(self, _("TEXT_INVALID_SMARTCARD"), exception=exc)
     except LocalDeviceNotFoundError as exc:
         if auth_method == DeviceFileType.PASSWORD:
             show_error(self, _("TEXT_CANNOT_SAVE_DEVICE"), exception=exc)
     except LocalDeviceError as exc:
         show_error(self, _("TEXT_CANNOT_SAVE_DEVICE"), exception=exc)
Exemplo n.º 23
0
 def _on_finished(self):
     show_info(self, _("TEXT_USER_GREET_SUCCESSFUL"))
     self.dialog.accept()
Exemplo n.º 24
0
 def _on_none_clicked(self):
     show_info(self, _("TEXT_GREET_USER_NONE_CODE_CLICKED"))
     self.failed.emit(None)
Exemplo n.º 25
0
 def _on_finished(self, device, password):
     show_info(self, _("TEXT_CLAIM_USER_SUCCESSFUL"))
     self.status = (device, password)
     self.dialog.accept()
Exemplo n.º 26
0
 def _on_copy_addr_clicked(self):
     desktop.copy_to_clipboard(self.invite_addr.to_url())
     show_info(self, _("TEXT_GREET_DEVICE_ADDR_COPIED_TO_CLIPBOARD"))
Exemplo n.º 27
0
 def on_revoke_success(self, job):
     button = job.ret
     show_info(
         self,
         _("TEXT_USER_REVOKE_SUCCESS_user").format(user=button.user_name))
     button.is_revoked = True
Exemplo n.º 28
0
 def _on_none_clicked(self):
     show_info(self, _("TEXT_CLAIM_DEVICE_NONE_CODE_CLICKED"))
     self.failed.emit(None)
Exemplo n.º 29
0
 def open_info_small(self):
     custom_dialogs.show_info(self,
                              message=SMALL_TEXT,
                              button_text="Continue")
Exemplo n.º 30
0
 def open_info_large(self):
     custom_dialogs.show_info(self,
                              message=LARGE_TEXT,
                              button_text="Continue")