60 |
void verify_show_signature_state (gpgme_signature_t sig); |
void verify_show_signature_state (gpgme_signature_t sig); |
61 |
|
|
62 |
|
|
|
/* Symbolic column IDs. */ |
|
|
enum { |
|
|
FM_COL_STAT = 0, |
|
|
FM_COL_NAME = 1, |
|
|
FM_COL_OP = 2 |
|
|
}; |
|
|
|
|
63 |
static const char *mm_files[] = {".mov", ".avi", ".mpg", ".mpeg", |
static const char *mm_files[] = {".mov", ".avi", ".mpg", ".mpeg", |
64 |
".mp3", ".wav", ".mid", ".wma", |
".mp3", ".wav", ".mid", ".wma", |
65 |
".gif", ".jpg", ".png", ".jpeg", ".dib", 0}; |
".gif", ".jpg", ".png", ".jpeg", ".dib", 0}; |
66 |
|
|
67 |
|
|
68 |
|
/* Add a new file to the model @fm. */ |
69 |
|
static void |
70 |
|
fm_model_add_file (fm_model_t *fm, fm_model_t file) |
71 |
|
{ |
72 |
|
fm_model_t m; |
73 |
|
|
74 |
|
if (!*fm) { |
75 |
|
*fm = file; |
76 |
|
return; |
77 |
|
} |
78 |
|
for (m = *fm; m->next; m = m->next) |
79 |
|
; |
80 |
|
m->next = file; |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
/* Search for a file model based on the name @name. */ |
85 |
|
static fm_model_t |
86 |
|
fm_model_find_file (fm_model_t fm, const char *name) |
87 |
|
{ |
88 |
|
fm_model_t m; |
89 |
|
|
90 |
|
for (m=fm; m; m=m->next) { |
91 |
|
if (!stricmp (m->name, name)) |
92 |
|
return m; |
93 |
|
} |
94 |
|
return NULL; |
95 |
|
} |
96 |
|
|
97 |
|
|
98 |
/* Check if the drive given by @fname is a floppy disc. |
/* Check if the drive given by @fname is a floppy disc. |
99 |
Return value: -1 for success. */ |
Return value: -1 for success. */ |
100 |
static int |
static int |
397 |
} |
} |
398 |
|
|
399 |
|
|
400 |
/* Build the File Manager list view control. */ |
/* Build the File Manager dialog context. */ |
401 |
int |
void |
402 |
fm_build (listview_ctrl_t *lv, HWND ctrl) |
fm_build (fm_info_t *r_fm, HWND ctrl) |
403 |
{ |
{ |
404 |
int i; |
int i; |
405 |
listview_ctrl_t c; |
fm_info_t fm; |
406 |
struct listview_column_s col[] = { |
struct listview_column_s col[] = { |
407 |
{0, 80, (char *)_("Status") }, |
{0, 80, (char *)_("Status") }, |
408 |
{1, 256, (char *)_("Name") }, |
{1, 256, (char *)_("Name") }, |
409 |
{2, 128, (char *)_("Operation") }, |
{2, 128, (char *)_("Operation") }, |
410 |
{0, 0, NULL} |
{0, 0, NULL} |
411 |
}; |
}; |
412 |
|
|
413 |
listview_new (&c, ctrl); |
fm = new fm_info_s; |
414 |
|
memset (fm, 0, sizeof *fm); |
415 |
|
listview_new (&fm->lv, ctrl); |
416 |
for (i = 0; col[i].width; i++) |
for (i = 0; col[i].width; i++) |
417 |
listview_add_column (c, &col[i]); |
listview_add_column (fm->lv, &col[i]); |
418 |
listview_set_ext_style (c); |
listview_set_ext_style (fm->lv); |
419 |
if (lv) |
fm->model = NULL; /*init*/ |
420 |
*lv = c; |
*r_fm = fm; |
|
return 0; |
|
421 |
} |
} |
422 |
|
|
423 |
|
|
424 |
/* Release the File Manager listview control. */ |
/* Release the file model. */ |
425 |
void |
static void |
426 |
fm_delete (listview_ctrl_t lv) |
fm_model_release (fm_model_t mod) |
427 |
{ |
{ |
428 |
if (lv) { |
fm_model_t m; |
429 |
listview_release(lv); |
|
430 |
|
while (mod) { |
431 |
|
m = mod->next; |
432 |
|
free_if_alloc (mod->name); |
433 |
|
free_if_alloc (mod->op); |
434 |
|
free_if_alloc (mod->status); |
435 |
|
free_if_alloc (mod); |
436 |
|
mod = m; |
437 |
} |
} |
438 |
} |
} |
439 |
|
|
440 |
|
|
441 |
|
/* Reset the File Manager info context. */ |
442 |
|
void |
443 |
|
fm_reset (fm_info_t fm) |
444 |
|
{ |
445 |
|
listview_del_all_items (fm->lv); |
446 |
|
fm_model_release (fm->model); |
447 |
|
fm->model = NULL; |
448 |
|
} |
449 |
|
|
450 |
|
|
451 |
|
/* Release the File Manager dialog context. */ |
452 |
|
void |
453 |
|
fm_delete (fm_info_t fm) |
454 |
|
{ |
455 |
|
if (!fm) |
456 |
|
return; |
457 |
|
if (fm->menu) |
458 |
|
DestroyMenu (fm->menu); |
459 |
|
listview_release (fm->lv); |
460 |
|
fm_model_release (fm->model); |
461 |
|
free_if_alloc (fm); |
462 |
|
} |
463 |
|
|
464 |
|
|
465 |
int |
int |
466 |
fm_state_new (fm_state_t * ctx) |
fm_state_new (fm_state_t * ctx) |
467 |
{ |
{ |
499 |
static int |
static int |
500 |
fm_check_for_entry (listview_ctrl_t lv, const char *file) |
fm_check_for_entry (listview_ctrl_t lv, const char *file) |
501 |
{ |
{ |
502 |
char name[512]; |
char name[MAX_PATH+128]; |
503 |
int i; |
int i; |
504 |
|
|
505 |
memset (name, 0, sizeof (name)); |
memset (name, 0, sizeof (name)); |
506 |
for (i = 0; i < listview_count_items (lv, 0); i++) { |
for (i = 0; i < listview_count_items (lv, 0); i++) { |
507 |
listview_get_item_text (lv, i, FM_COL_NAME, name, sizeof (name) - 1); |
listview_get_item_text (lv, i, FM_COL_NAME, name, sizeof (name) - 1); |
508 |
if (!strcmp( name, file)) |
if (!strcmp (name, file)) |
509 |
return 1; /* found */ |
return 1; /* found */ |
510 |
} |
} |
511 |
|
|
514 |
|
|
515 |
|
|
516 |
static int |
static int |
517 |
fm_set_ftype (listview_ctrl_t lv, const char *name) |
fm_set_ftype (listview_ctrl_t lv, fm_model_t *fm, const char *name) |
518 |
{ |
{ |
519 |
|
fm_model_t m; |
520 |
const char *type; |
const char *type; |
521 |
int rc; |
int rc; |
522 |
|
|
523 |
rc = fm_check_for_entry (lv, name); |
rc = fm_check_for_entry (lv, name); |
524 |
if (rc) |
if (rc) |
525 |
return 0; |
return 0; |
526 |
|
m = new fm_model_s; |
527 |
|
memset (m, 0, sizeof *m); |
528 |
type = fm_get_file_type (name, NULL); |
type = fm_get_file_type (name, NULL); |
529 |
if (!type || !strcmp (type, "UNKNOWN")) |
if (!type || !strcmp (type, "UNKNOWN")) |
530 |
type = gnupg_check_file_ext (name, NULL); |
type = gnupg_check_file_ext (name, NULL); |
531 |
rc = listview_add_item (lv, " "); |
listview_add_item2 (lv, " ", (void*)m); |
|
if (rc) |
|
|
return -1; |
|
532 |
listview_add_sub_item (lv, 0, FM_COL_STAT, type); |
listview_add_sub_item (lv, 0, FM_COL_STAT, type); |
533 |
listview_add_sub_item (lv, 0, FM_COL_NAME, name); |
listview_add_sub_item (lv, 0, FM_COL_NAME, name); |
534 |
|
m->name = m_strdup (name); |
535 |
|
m->status = m_strdup (type); |
536 |
|
m->op = NULL; |
537 |
|
fm_model_add_file (fm, m); |
538 |
return 0; |
return 0; |
539 |
} |
} |
540 |
|
|
541 |
|
|
542 |
/* Add all files from the directory @path to the list view @lv. */ |
/* Add all files from the directory @path to the list view @lv. */ |
543 |
static int |
static int |
544 |
fm_add_dir_files (listview_ctrl_t lv, char *path) |
fm_add_dir_files (listview_ctrl_t lv, fm_model_t *fm, char *path) |
545 |
{ |
{ |
546 |
struct _finddata_t fd; |
struct _finddata_t fd; |
547 |
char *p; |
char *p; |
557 |
p[strlen (path)-1] = 0; |
p[strlen (path)-1] = 0; |
558 |
strcat (p, fd.name); |
strcat (p, fd.name); |
559 |
if (!is_directory (p)) |
if (!is_directory (p)) |
560 |
fm_set_ftype (lv, p); |
fm_set_ftype (lv, fm, p); |
561 |
free_if_alloc (p); |
free_if_alloc (p); |
562 |
} while (_findnext (hd, &fd) == 0); |
} while (_findnext (hd, &fd) == 0); |
563 |
_findclose (hd); |
_findclose (hd); |
568 |
/* Add the drag & drop files from @dd_files to the |
/* Add the drag & drop files from @dd_files to the |
569 |
list view control @lv. */ |
list view control @lv. */ |
570 |
int |
int |
571 |
fm_add_dropped_files (listview_ctrl_t lv, HDROP dd_files) |
fm_add_dropped_files (fm_info_t fm, HDROP dd_files) |
572 |
{ |
{ |
573 |
char name[384+4]; |
char name[384+4]; |
574 |
int nfiles; |
int nfiles; |
580 |
for (i = 0; i < nfiles; i++) { |
for (i = 0; i < nfiles; i++) { |
581 |
DragQueryFile (dd_files, i, name, sizeof (name) -1); |
DragQueryFile (dd_files, i, name, sizeof (name) -1); |
582 |
if (is_directory (name)) |
if (is_directory (name)) |
583 |
rc = fm_add_dir_files (lv, name); |
rc = fm_add_dir_files (fm->lv, &fm->model, name); |
584 |
else |
else |
585 |
rc = fm_set_ftype (lv, name); |
rc = fm_set_ftype (fm->lv, &fm->model, name); |
586 |
if (rc == -1) |
if (rc == -1) |
587 |
break; /* XXX: fixme? */ |
break; /* XXX: fixme? */ |
588 |
} |
} |
595 |
figure out the type of it. |
figure out the type of it. |
596 |
Return value: 0 on success. */ |
Return value: 0 on success. */ |
597 |
static int |
static int |
598 |
add_single_file (listview_ctrl_t lv, const char *name) |
add_single_file (listview_ctrl_t lv, fm_model_t *fm, const char *name) |
599 |
{ |
{ |
600 |
|
fm_model_t m; |
601 |
const char *type; |
const char *type; |
602 |
int rc = 0; |
int rc = 0; |
603 |
|
|
604 |
type = fm_get_file_type (name, NULL); |
type = fm_get_file_type (name, NULL); |
605 |
if (!type) |
if (!type) |
606 |
return WPTERR_FILE_OPEN; |
return WPTERR_FILE_OPEN; |
607 |
|
m = new fm_model_s; |
608 |
|
memset (m, 0, sizeof *m); |
609 |
if (!strcmp (type, "UNKNOWN")) |
if (!strcmp (type, "UNKNOWN")) |
610 |
type = gnupg_check_file_ext (name, NULL); |
type = gnupg_check_file_ext (name, NULL); |
611 |
rc = listview_add_item (lv, ""); |
rc = listview_add_item2 (lv, "", (void*)m); |
612 |
if (!rc) { |
if (!rc) { |
613 |
listview_add_sub_item (lv, 0, FM_COL_STAT, type); |
listview_add_sub_item (lv, 0, FM_COL_STAT, type); |
614 |
listview_add_sub_item (lv, 0, FM_COL_NAME, name); |
listview_add_sub_item (lv, 0, FM_COL_NAME, name); |
615 |
} |
} |
616 |
|
m->status = m_strdup (type); |
617 |
|
m->name = m_strdup (name); |
618 |
|
m->op = NULL; |
619 |
|
fm_model_add_file (fm, m); |
620 |
return rc; |
return rc; |
621 |
} |
} |
622 |
|
|
624 |
/* Use the common Open-File-Dialog to allow the user to |
/* Use the common Open-File-Dialog to allow the user to |
625 |
add one ore more selected files to the listview @lv. */ |
add one ore more selected files to the listview @lv. */ |
626 |
int |
int |
627 |
fm_add_opened_files (listview_ctrl_t lv, HWND dlg) |
fm_add_opened_files (fm_info_t fm, HWND dlg) |
628 |
{ |
{ |
629 |
OPENFILENAME open; |
OPENFILENAME open; |
630 |
char file[512], name[MAX_PATH+1]; |
char file[512], name[MAX_PATH+1]; |
666 |
path = m_strdup (name); |
path = m_strdup (name); |
667 |
else { |
else { |
668 |
char *p = make_filename (path, name, NULL); |
char *p = make_filename (path, name, NULL); |
669 |
rc = add_single_file (lv, p); |
rc = add_single_file (fm->lv, &fm->model, p); |
670 |
free_if_alloc (p); |
free_if_alloc (p); |
671 |
} |
} |
672 |
n++; |
n++; |
673 |
} |
} |
674 |
if (n == 1) /* single file selected. */ |
if (n == 1) /* single file selected. */ |
675 |
rc = add_single_file (lv, path); |
rc = add_single_file (fm->lv, &fm->model, path); |
676 |
free_if_alloc (path); |
free_if_alloc (path); |
677 |
return rc; |
return rc; |
678 |
} |
} |
856 |
fm_clearsign_8bit (listview_ctrl_t lv, fm_state_s *ctx) |
fm_clearsign_8bit (listview_ctrl_t lv, fm_state_s *ctx) |
857 |
{ |
{ |
858 |
FILE *f; |
FILE *f; |
859 |
byte buf[32]; |
BYTE buf[32]; |
860 |
char name[256]; |
char name[256]; |
861 |
int i, n, cnt=0; |
int i, n, cnt=0; |
862 |
|
|
2002 |
static int CALLBACK |
static int CALLBACK |
2003 |
fm_cmp_cb (LPARAM first, LPARAM second, LPARAM sortby) |
fm_cmp_cb (LPARAM first, LPARAM second, LPARAM sortby) |
2004 |
{ |
{ |
2005 |
const char *a = ""; |
fm_model_t a, b; |
2006 |
const char *b = ""; |
int cmpres = 0; |
2007 |
|
|
2008 |
|
a = (fm_model_t)first; |
2009 |
|
b = (fm_model_t)second; |
2010 |
|
if (!a || !b) |
2011 |
|
return 0; |
2012 |
|
|
2013 |
switch ((int)sortby) { |
switch ((int)sortby) { |
2014 |
case FM_SORT_STAT: |
case FM_COL_STAT: |
2015 |
|
cmpres = stricmp (a->status, b->status); |
2016 |
break; |
break; |
2017 |
case FM_SORT_NAME: |
|
2018 |
|
case FM_COL_NAME: |
2019 |
|
cmpres = stricmp (a->name, b->name); |
2020 |
break; |
break; |
2021 |
case FM_SORT_OP: |
|
2022 |
|
case FM_COL_OP: |
2023 |
|
if (a->op && b->op) |
2024 |
|
cmpres = stricmp (a->op, b->op); |
2025 |
break; |
break; |
2026 |
} |
} |
2027 |
return stricmp (a, b); |
return cmpres; |
2028 |
} |
} |
2029 |
|
|
2030 |
|
|
2031 |
/* Sort the list items from @lv with the mode given by @sortby. */ |
/* Sort the list items from @lv with the mode given by @sortby. */ |
2032 |
int |
int |
2033 |
fm_sort (listview_ctrl_t lv, int sortby) |
fm_sort (listview_ctrl_t lv, int sortby) |
2034 |
{ |
{ |
2035 |
return listview_sort_items (lv, sortby, fm_cmp_cb); |
return ListView_SortItems (lv->ctrl, fm_cmp_cb, (LPARAM)sortby); |
2036 |
} |
} |
2037 |
|
|
2038 |
|
|