HelenOS sources
This source file includes following definitions.
- navigator_verify_dlg
- verify_wfunc
- verify_bok
- verify_bcancel
- verify_close
- verify_abort_query
- verify_progress
#include <fmgt.h>
#include <stdlib.h>
#include <str_error.h>
#include <ui/fixed.h>
#include <ui/filelist.h>
#include <ui/msgdialog.h>
#include <ui/resource.h>
#include <ui/ui.h>
#include <ui/window.h>
#include <stdbool.h>
#include <str.h>
#include "dlg/progress.h"
#include "dlg/verifydlg.h"
#include "menu.h"
#include "nav.h"
#include "types/verify.h"
#include "verify.h"
static void verify_bok(verify_dlg_t *, void *);
static void verify_bcancel(verify_dlg_t *, void *);
static void verify_close(verify_dlg_t *, void *);
static verify_dlg_cb_t verify_cb = {
.bok = verify_bok,
.bcancel = verify_bcancel,
.close = verify_close
};
static bool verify_abort_query(void *);
static void verify_progress(void *, fmgt_progress_t *);
static fmgt_cb_t verify_fmgt_cb = {
.abort_query = verify_abort_query,
.io_error_query = navigator_io_error_query,
.progress = verify_progress,
};
void navigator_verify_dlg(navigator_t *navigator, fmgt_flist_t *flist)
{
verify_dlg_t *dlg;
errno_t rc;
rc = verify_dlg_create(navigator->ui, flist, &dlg);
if (rc != EOK)
return;
verify_dlg_set_cb(dlg, &verify_cb, (void *)navigator);
}
static void verify_wfunc(void *arg)
{
fmgt_t *fmgt = NULL;
navigator_verify_job_t *job = (navigator_verify_job_t *)arg;
char *msg = NULL;
navigator_t *nav = job->navigator;
ui_msg_dialog_t *dialog = NULL;
ui_msg_dialog_params_t params;
errno_t rc;
int rv;
rc = fmgt_create(&fmgt);
if (rc != EOK) {
return;
}
fmgt_set_cb(fmgt, &verify_fmgt_cb, (void *)nav);
fmgt_set_init_update(fmgt, true);
rc = fmgt_verify(fmgt, job->flist);
if (rc != EOK) {
rv = asprintf(&msg, "Error verifying file(s) (%s).",
str_error(rc));
if (rv < 0)
return;
goto error;
}
fmgt_destroy(fmgt);
ui_lock(nav->ui);
progress_dlg_destroy(nav->progress_dlg);
navigator_refresh_panels(nav);
ui_unlock(nav->ui);
fmgt_flist_destroy(job->flist);
free(job);
return;
error:
fmgt_destroy(fmgt);
ui_lock(nav->ui);
progress_dlg_destroy(nav->progress_dlg);
navigator_refresh_panels(nav);
ui_msg_dialog_params_init(¶ms);
params.caption = "Error";
params.text = msg;
(void) ui_msg_dialog_create(nav->ui, ¶ms, &dialog);
ui_unlock(nav->ui);
free(msg);
}
static void verify_bok(verify_dlg_t *dlg, void *arg)
{
navigator_t *nav = (navigator_t *)arg;
ui_msg_dialog_t *dialog = NULL;
navigator_verify_job_t *job;
ui_msg_dialog_params_t params;
progress_dlg_params_t pd_params;
char *msg = NULL;
errno_t rc;
verify_dlg_destroy(dlg);
job = calloc(1, sizeof(navigator_verify_job_t));
if (job == NULL)
return;
job->navigator = nav;
job->flist = dlg->flist;
dlg->flist = NULL;
progress_dlg_params_init(&pd_params);
pd_params.caption = "Verifying";
rc = progress_dlg_create(nav->ui, &pd_params, &nav->progress_dlg);
if (rc != EOK) {
msg = str_dup("Out of memory.");
if (msg == NULL)
return;
goto error;
}
progress_dlg_set_cb(nav->progress_dlg, &navigator_progress_cb,
(void *)nav);
rc = navigator_worker_start(nav, verify_wfunc, (void *)job);
if (rc != EOK) {
msg = str_dup("Out of memory.");
if (msg == NULL)
return;
goto error;
}
return;
error:
ui_msg_dialog_params_init(¶ms);
params.caption = "Error";
params.text = msg;
(void) ui_msg_dialog_create(nav->ui, ¶ms, &dialog);
free(msg);
}
static void verify_bcancel(verify_dlg_t *dlg, void *arg)
{
(void)arg;
verify_dlg_destroy(dlg);
}
static void verify_close(verify_dlg_t *dlg, void *arg)
{
(void)arg;
verify_dlg_destroy(dlg);
}
static bool verify_abort_query(void *arg)
{
navigator_t *nav = (navigator_t *)arg;
return nav->abort_op;
}
static void verify_progress(void *arg, fmgt_progress_t *progress)
{
navigator_t *nav = (navigator_t *)arg;
progress_dlg_set_progress(nav->progress_dlg, progress);
}
HelenOS homepage, sources at GitHub