Ejemplo n.º 1
0
    def __init__(self, jobs_ctx, event_bus, config, **kwargs):
        super().__init__(**kwargs)
        self.setupUi(self)

        if platform.system() != "Windows" and platform.system() != "Darwin":
            return

        self.widget_info = NewVersionInfo(parent=self)
        self.widget_available = NewVersionAvailable(parent=self)
        self.widget_available.hide()
        self.layout.addWidget(self.widget_info)
        self.layout.addWidget(self.widget_available)

        self.widget_info.close_clicked.connect(self.ignore)
        self.widget_available.close_clicked.connect(self.ignore)
        self.widget_available.download_clicked.connect(self.download)

        self.jobs_ctx = jobs_ctx
        self.event_bus = event_bus
        self.config = config

        self.check_new_version_success.connect(
            self.on_check_new_version_success)
        self.check_new_version_error.connect(self.on_check_new_version_error)

        self.version_job = self.jobs_ctx.submit_job(
            ThreadSafeQtSignal(self, "check_new_version_success"),
            ThreadSafeQtSignal(self, "check_new_version_error"),
            _do_check_new_version,
            url=self.config.gui_check_version_url,
        )
        self.setWindowFlags(Qt.SplashScreen)
Ejemplo n.º 2
0
    def __init__(self, jobs_ctx, greeter):
        super().__init__()
        self.setupUi(self)
        self.jobs_ctx = jobs_ctx
        self.greeter = greeter
        self.get_requests_job = None
        self.create_user_job = None

        self.widget_info.hide()
        self.label_waiting.show()

        self.line_edit_user_full_name.textChanged.connect(self.check_infos)
        self.line_edit_user_email.textChanged.connect(self.check_infos)
        self.line_edit_device.textChanged.connect(self.check_infos)

        # self.combo_profile.addItem(_("TEXT_USER_PROFILE_OUTSIDER"), UserProfile.OUTSIDER)
        self.combo_profile.addItem(_("TEXT_USER_PROFILE_STANDARD"),
                                   UserProfile.STANDARD)
        self.combo_profile.addItem(_("TEXT_USER_PROFILE_ADMIN"),
                                   UserProfile.ADMIN)
        self.combo_profile.setCurrentIndex(0)

        self.get_requests_success.connect(self._on_get_requests_success)
        self.get_requests_error.connect(self._on_get_requests_error)
        self.create_user_success.connect(self._on_create_user_success)
        self.create_user_error.connect(self._on_create_user_error)
        self.button_create_user.clicked.connect(self._on_create_user_clicked)

        self.get_requests_job = self.jobs_ctx.submit_job(
            ThreadSafeQtSignal(self, "get_requests_success", QtToTrioJob),
            ThreadSafeQtSignal(self, "get_requests_error", QtToTrioJob),
            self.greeter.get_claim_requests,
        )
Ejemplo n.º 3
0
 def invite_device(self):
     self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "invite_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "invite_error", QtToTrioJob),
         _do_invite_device,
         client=self.client,
     )
Ejemplo n.º 4
0
    def bootstrap_clicked(self):
        assert not self.bootstrap_job

        try:
            human_handle = HumanHandle(email=self.line_edit_email.text(),
                                       label=self.line_edit_login.text())
        except ValueError as exc:
            if hasattr(exc, "args") and len(exc.args) > 0:
                if exc.args[0] == "Invalid email address":
                    err_msg = "TEXT_BOOTSTRAP_ORG_INVALID_EMAIL"
                elif exc.args[0] == "Invalid label":
                    err_msg = "TEXT_CLAIM_USER_INVALID_HUMAN_HANDLE"
                else:
                    err_msg = "TEXT_BOOTSTRAP_ORG_UNKNOWN_FAILURE"
            else:
                err_msg = "TEXT_BOOTSTRAP_ORG_UNKNOWN_FAILURE"
            show_error(self, _(err_msg), exception=exc)
            return

        self.bootstrap_job = self.jobs_ctx.submit_job(
            ThreadSafeQtSignal(self, "bootstrap_success"),
            ThreadSafeQtSignal(self, "bootstrap_error"),
            _do_bootstrap_organization,
            config_dir=self.config.config_dir,
            password=self.line_edit_password.text(),
            password_check=self.line_edit_password_check.text(),
            human_handle=human_handle,
            device_label=self.line_edit_device.text(),
            bootstrap_addr=self.addr,
        )
        self.check_infos()
Ejemplo n.º 5
0
 def _on_good_greeter_code_clicked(self):
     self.widget_greeter_code.setDisabled(True)
     self.signify_trust_job = self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "signify_trust_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "signify_trust_error", QtToTrioJob),
         self.claimer.signify_trust,
     )
Ejemplo n.º 6
0
 def _on_good_claimer_code_clicked(self):
     self.widget_claimer_code.hide()
     self.label_wait_info.show()
     self.signify_trust_job = self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "signify_trust_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "signify_trust_error", QtToTrioJob),
         self.greeter.signify_trust,
     )
Ejemplo n.º 7
0
 def _on_button_send_email_clicked(self):
     self.button_send_email.setDisabled(True)
     self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "send_email_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "send_email_error", QtToTrioJob),
         _do_send_email,
         client=self.client,
     )
Ejemplo n.º 8
0
 def _on_button_start_clicked(self):
     self.button_start.setDisabled(True)
     self.button_start.setText(_("TEXT_CLAIM_DEVICE_WAITING"))
     self.wait_peer_job = self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "wait_peer_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "wait_peer_error", QtToTrioJob),
         self.claimer.wait_peer,
     )
Ejemplo n.º 9
0
 def _on_button_start_clicked(self, checked):
     self.button_start.setDisabled(True)
     self.button_start.setText(_("TEXT_GREET_USER_WAITING"))
     self.wait_peer_job = self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "wait_peer_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "wait_peer_error", QtToTrioJob),
         self.greeter.wait_peer,
     )
Ejemplo n.º 10
0
 def _get_organization_stats(self):
     self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "organization_stats_success",
                            QtToTrioJob),
         ThreadSafeQtSignal(self, "organization_stats_error", QtToTrioJob),
         _do_get_organization_stats,
         client=self.client,
     )
Ejemplo n.º 11
0
 def unmount_workspace(self, workspace_id, timestamp=None):
     self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "unmount_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "unmount_error", QtToTrioJob),
         _do_workspace_unmount,
         client=self.client,
         workspace_id=workspace_id,
         timestamp=timestamp,
     )
Ejemplo n.º 12
0
 def _on_workspace_name_input_finished(return_code, workspace_name):
     if return_code and workspace_name:
         self.jobs_ctx.submit_job(
             ThreadSafeQtSignal(self, "create_success", QtToTrioJob),
             ThreadSafeQtSignal(self, "create_error", QtToTrioJob),
             _do_workspace_create,
             client=self.client,
             workspace_name=workspace_name,
         )
Ejemplo n.º 13
0
 def _run_greeter(self):
     self.greeter_job = self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "greeter_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "greeter_error", QtToTrioJob),
         self.greeter.run,
         client=self.client,
         token=self.token,
     )
     self._goto_page1()
Ejemplo n.º 14
0
 def _on_revoke_question_finished(return_code, answer):
     if return_code and answer == _("ACTION_USER_REVOCATION_CONFIRM"):
         self.jobs_ctx.submit_job(
             ThreadSafeQtSignal(self, "revoke_success", QtToTrioJob),
             ThreadSafeQtSignal(self, "revoke_error", QtToTrioJob),
             _do_revoke_user,
             client=self.client,
             user_info=user_info,
         )
Ejemplo n.º 15
0
 def _on_user_email_input_finished(return_code, user_email):
     if return_code and user_email:
         self.jobs_ctx.submit_job(
             ThreadSafeQtSignal(self, "invite_user_success",
                                QtToTrioJob),
             ThreadSafeQtSignal(self, "invite_user_error", QtToTrioJob),
             _do_invite_user,
             client=self.client,
             email=user_email,
         )
Ejemplo n.º 16
0
 def list_workspaces(self):
     if not self.has_workspaces_displayed():
         self.spinner.spinner_movie.start()
         self.spinner.show()
     self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "list_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "list_error", QtToTrioJob),
         _do_workspace_list,
         client=self.client,
     )
Ejemplo n.º 17
0
        def _on_workspace_reencryption_question_finished(return_code, answer):
            if not return_code or answer != _(
                    "ACTION_WORKSPACE_REENCRYPTION_CONFIRM"):
                return

            @contextmanager
            def _handle_fs_errors():
                try:
                    yield
                except FSBackendOfflineError as exc:
                    raise JobResultError(ret=workspace_id,
                                         status="offline-backend",
                                         origin=exc)
                except FSWorkspaceNoAccess as exc:
                    raise JobResultError(ret=workspace_id,
                                         status="access-error",
                                         origin=exc)
                except FSWorkspaceNotFoundError as exc:
                    raise JobResultError(ret=workspace_id,
                                         status="not-found",
                                         origin=exc)
                except FSError as exc:
                    raise JobResultError(ret=workspace_id,
                                         status="fs-error",
                                         origin=exc)

            async def _reencrypt(on_progress, workspace_id):
                with _handle_fs_errors():
                    if reencryption_already_in_progress:
                        job = await self.client.user_fs.workspace_continue_reencryption(
                            workspace_id)
                    else:
                        job = await self.client.user_fs.workspace_start_reencryption(
                            workspace_id)
                while True:
                    with _handle_fs_errors():
                        total, done = await job.do_one_batch()
                    on_progress.emit(workspace_id, total, done)
                    if total == done:
                        break
                return workspace_id

            self.reencrypting.add(workspace_id)

            self.jobs_ctx.submit_job(
                ThreadSafeQtSignal(self, "workspace_reencryption_success",
                                   QtToTrioJob),
                ThreadSafeQtSignal(self, "workspace_reencryption_error",
                                   QtToTrioJob),
                _reencrypt,
                on_progress=ThreadSafeQtSignal(
                    self, "workspace_reencryption_progress", EntryID, int,
                    int),
                workspace_id=workspace_id,
            )
Ejemplo n.º 18
0
 def _on_claim_clicked(self):
     device_label = self.line_edit_device.text()
     self.button_ok.setDisabled(True)
     self.widget_info.setDisabled(True)
     self.label_wait.show()
     self.claim_job = self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "claim_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "claim_error", QtToTrioJob),
         self.claimer.claim_device,
         device_label=device_label,
     )
Ejemplo n.º 19
0
 def _on_folder_name_finished(return_code, folder_name):
     if return_code and folder_name:
         self.jobs_ctx.submit_job(
             ThreadSafeQtSignal(self, "folder_create_success",
                                QtToTrioJob),
             ThreadSafeQtSignal(self, "folder_create_error",
                                QtToTrioJob),
             _do_folder_create,
             workspace_fs=self.workspace_fs,
             path=self.current_directory / folder_name,
         )
Ejemplo n.º 20
0
 def reset(self):
     self.spinner.spinner_movie.start()
     self.spinner.show()
     self.widget_users.hide()
     self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "get_users_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "get_users_error", QtToTrioJob),
         _do_get_users,
         client=self.client,
         workspace_fs=self.workspace_fs,
     )
Ejemplo n.º 21
0
 def _on_delete_file_question_finished(return_code, answer):
     if return_code and (answer == _("ACTION_FILE_DELETE")
                         or answer == _("ACTION_FILE_DELETE_MULTIPLE")):
         self.jobs_ctx.submit_job(
             ThreadSafeQtSignal(self, "delete_success", QtToTrioJob),
             ThreadSafeQtSignal(self, "delete_error", QtToTrioJob),
             _do_delete,
             workspace_fs=self.workspace_fs,
             files=[(self.current_directory / f.name, f.type)
                    for f in files],
         )
Ejemplo n.º 22
0
 def _on_cancel_invitation_question_finished(return_code, answer):
     if return_code and answer == _(
             "TEXT_USER_INVITE_CANCEL_INVITE_ACCEPT"):
         self.jobs_ctx.submit_job(
             ThreadSafeQtSignal(self, "cancel_invitation_success",
                                QtToTrioJob),
             ThreadSafeQtSignal(self, "cancel_invitation_error",
                                QtToTrioJob),
             _do_cancel_invitation,
             client=self.client,
             token=token,
         )
Ejemplo n.º 23
0
 def _rename_dialog_finished(return_code, text):
     if not return_code or not text:
         return
     self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "rename_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "rename_error", QtToTrioJob),
         _do_workspace_rename,
         client=self.client,
         workspace_id=workspace_button.workspace_fs.workspace_id,
         new_name=text,
         button=workspace_button,
     )
Ejemplo n.º 24
0
 def _on_signify_trust_success(self, job):
     if self.signify_trust_job is not job:
         return
     self.signify_trust_job = None
     assert job
     assert job.is_finished()
     assert job.status == "ok"
     self.get_claimer_sas_job = self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "get_claimer_sas_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "get_claimer_sas_error", QtToTrioJob),
         self.claimer.get_claimer_sas,
     )
Ejemplo n.º 25
0
 def reset(self):
     self.layout_devices.clear()
     self.button_previous_page.hide()
     self.button_next_page.hide()
     self.spinner.spinner_movie.start()
     self.spinner.show()
     self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "list_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "list_error", QtToTrioJob),
         _do_list_devices,
         client=self.client,
         page=self._page,
     )
Ejemplo n.º 26
0
 def on_filter(self):
     self._page = 1
     pattern = self.line_edit_search.text()
     if len(pattern) < 2:
         return self.reset()
     self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "list_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "list_error", QtToTrioJob),
         _do_list_devices,
         client=self.client,
         page=self._page,
         pattern=pattern,
     )
Ejemplo n.º 27
0
 def _run_claimer(self):
     self.claimer_job = self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "claimer_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "claimer_error", QtToTrioJob),
         self.claimer.run,
         addr=self.addr,
         config=self.config,
     )
     self.retrieve_info_job = self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "retrieve_info_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "retrieve_info_error", QtToTrioJob),
         self.claimer.retrieve_info,
     )
Ejemplo n.º 28
0
 def load(self, directory, default_selection=None):
     self.table_files.clear()
     self.table_files.setStyleSheet("background-color: #EFEFEF;")
     self.spinner.spinner_movie.start()
     self.spinner.show()
     self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "folder_stat_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "folder_stat_error", QtToTrioJob),
         _do_folder_stat,
         workspace_fs=self.workspace_fs,
         path=directory,
         default_selection=default_selection,
     )
Ejemplo n.º 29
0
 def _on_rename_one_file_finished(return_code, new_name):
     if return_code and new_name:
         self.jobs_ctx.submit_job(
             ThreadSafeQtSignal(self, "rename_success",
                                QtToTrioJob),
             ThreadSafeQtSignal(self, "rename_error", QtToTrioJob),
             _do_rename,
             workspace_fs=self.workspace_fs,
             paths=[(
                 self.current_directory / files[0].name,
                 self.current_directory / new_name,
                 files[0].uuid,
             )],
         )
Ejemplo n.º 30
0
 def _on_get_greeter_sas_success(self, job):
     if self.get_greeter_sas_job != job:
         return
     self.get_greeter_sas_job = None
     assert job
     assert job.is_finished()
     assert job.status == "ok"
     greeter_sas = job.ret
     self.line_edit_greeter_code.setText(str(greeter_sas))
     self.wait_peer_trust_job = self.jobs_ctx.submit_job(
         ThreadSafeQtSignal(self, "wait_peer_trust_success", QtToTrioJob),
         ThreadSafeQtSignal(self, "wait_peer_trust_error", QtToTrioJob),
         self.greeter.wait_peer_trust,
     )