1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
|
/**
* Copyright (C) 2021-2024 Saturneric <[email protected]>
*
* This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GpgFrontend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
*
* The initial version of the source code is inherited from
* the gpg4usb project, which is under GPL-3.0-or-later.
*
* All the source code of GpgFrontend was modified and released by
* Saturneric <[email protected]> starting on May 12, 2021.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#pragma once
#include "core/typedef/CoreTypedef.h"
#include "core/typedef/GpgTypedef.h"
#include "ui/main_window/GeneralMainWindow.h"
#include "ui/struct/GpgOperaResult.h"
namespace GpgFrontend {
class GpgPassphraseContext;
class GpgResultAnalyse;
class GpgVerifyResultAnalyse;
} // namespace GpgFrontend
namespace GpgFrontend::UI {
class KeyList;
class TextEdit;
class InfoBoardWidget;
struct GpgOperaContext;
struct GpgOperaContextBasement;
/**
* @brief
*
*/
class MainWindow : public GeneralMainWindow {
Q_OBJECT
public:
/**
*
*/
struct OperationMenu {
using OperationType = unsigned int;
static constexpr OperationType kNone = 0;
static constexpr OperationType kEncrypt = 1 << 0;
static constexpr OperationType kSign = 1 << 1;
static constexpr OperationType kDecrypt = 1 << 2;
static constexpr OperationType kVerify = 1 << 3;
static constexpr OperationType kEncryptAndSign = 1 << 4;
static constexpr OperationType kDecryptAndVerify = 1 << 5;
};
/**
* @brief
*
*/
MainWindow();
/**
* @details ONLY Called from main()
*/
void Init() noexcept;
signals:
/**
* @brief
*/
void SignalLoaded();
/**
* @brief
*/
void SignalRestartApplication(int);
/**
* @brief
*/
void SignalUIRefresh();
/**
* @brief
*/
void SignalKeyDatabaseRefresh();
public slots:
/**
* @brief
*/
void SlotSetStatusBarText(const QString& text);
protected:
/**
* @details Close event shows a save dialog, if there are unsaved documents on
* exit.
* @param event
*/
void closeEvent(QCloseEvent* event) override;
public slots:
/**
* @details refresh and enable specify crypto-menu actions.
*/
void SlotUpdateCryptoMenuStatus(unsigned int type);
/**
* @details Open a new tab for path
*/
void SlotOpenFile(const QString& path);
/**
* @details encrypt the text of currently active textedit-page
* with the currently checked keys
*/
void SlotEncrypt();
/**
* @details encrypt and sign the text of currently active textedit-page
* with the currently checked keys
*/
void SlotEncryptSign();
/**
* @details Show a passphrase dialog and decrypt the text of currently active
* tab.
*/
void SlotDecrypt();
/**
* @details Sign the text of currently active tab with the checked private
* keys
*/
void SlotSign();
/**
* @details Verify the text of currently active tab and show verify
* information. If document is signed with a key, which is not in keylist,
* show import missing key from keyserver in Menu of verifynotification.
*/
void SlotVerify();
/**
* @brief
*
*/
void SlotVerifyEML();
/**
* @brief
*
*/
void SlotDecryptEML();
/**
* @brief
*
*/
void SlotSignEML();
/**
* @brief
*
*/
void SlotEncryptEML();
/**
* @brief
*
*/
void SlotEncryptSignEML();
/**
* @brief
*
*/
void SlotDecryptVerifyEML();
/**
* @details decrypt and verify the text of currently active textedit-page
* with the currently checked keys
*/
void SlotDecryptVerify();
/**
* @details Open dialog for encrypting file.
*/
void SlotFileEncrypt(const QStringList& paths, bool ascii);
/**
* @brief
*
* @param path
*/
void SlotFileDecrypt(const QStringList& paths);
/**
* @brief
*
* @param path
*/
void SlotFileSign(const QStringList& paths, bool ascii);
/**
* @brief
*
* @param path
*/
void SlotFileVerify(const QStringList& paths);
/**
* @brief
*
* @param path
*/
void SlotFileVerifyEML(const QString& path);
/**
* @brief
*
* @param path
*/
void SlotFileEncryptSign(const QStringList& paths, bool ascii);
/**
* @brief
*
* @param path
*/
void SlotFileDecryptVerify(const QStringList& paths);
/**
* @details get value of member restartNeeded to needed.
* @param needed true, if application has to be restarted
*/
void SlotSetRestartNeeded(int);
/**
* @brief
*
*/
void SlotGeneralEncrypt(bool);
/**
* @brief
*
*/
void SlotGeneralDecrypt(bool);
/**
* @brief
*
*/
void SlotGeneralSign(bool);
/**
* @brief
*
*/
void SlotGeneralVerify(bool);
/**
* @brief
*
*/
void SlotGeneralEncryptSign(bool);
/**
* @brief
*
*/
void SlotGeneralDecryptVerify(bool);
private slots:
/**
* @brief
*
*/
void slot_refresh_current_file_view();
/**
* @details Show the details of the first of the first of selected keys
*/
void slot_show_key_details();
/**
* @details Refresh key information of selected keys from default keyserver
*/
void refresh_keys_from_key_server();
/**
* @details upload the selected key to the keyserver
*/
void upload_key_to_server();
/**
* @details Open find widget.
*/
void slot_find();
/**
* @details start the wizard
*/
void slot_start_wizard();
/**
* @details Import keys from currently active tab to keylist if possible.
*/
void slot_import_key_from_edit();
/**
* @details Append the selected keys to currently active textedit.
*/
void slot_append_selected_keys();
/**
* @brief
*
*/
void slot_append_keys_create_datetime();
/**
* @brief
*
*/
void slot_append_keys_expire_datetime();
/**
* @brief
*
*/
void slot_append_keys_fingerprint();
/**
* @details Copy the mailaddress of selected key to clipboard.
* Method for keylists contextmenu.
*/
void slot_copy_mail_address_to_clipboard();
/**
* @details Copy the mailaddress of selected key to clipboard.
* Method for keylists contextmenu.
*/
void slot_copy_default_uid_to_clipboard();
/**
* @details Copy the mailaddress of selected key to clipboard.
* Method for keylists contextmenu.
*/
void slot_copy_key_id_to_clipboard();
/**
* @details Open key management dialog.
*/
void slot_open_key_management();
/**
* @details Open File Opera Tab
*/
void slot_open_file_tab();
/**
* @details Open settings-dialog.
*/
void slot_open_settings_dialog();
/**
* @details Replace double linebreaks by single linebreaks in currently active
* tab.
*/
void slot_clean_double_line_breaks();
/**
* @details Cut the existing PGP header and footer from current tab.
*/
void slot_cut_pgp_header();
/**
* @details Add PGP header and footer to current tab.
*/
void slot_add_pgp_header();
/**
* @details Disable tab related actions, if number of tabs is 0.
* @param number number of the opened tabs and -1, if no tab is opened
*/
void slot_switch_menu_control_mode(int);
/**
* @details called when need to upgrade.
*/
void slot_version_upgrade_notify();
/**
* @details
*/
void slot_add_key_2_favorite();
/**
* @details
*/
void slot_remove_key_from_favorite();
/**
* @details
*/
void slot_set_owner_trust_level_of_key();
/**
* @brief
*
*/
void slot_verify_email_by_eml_data(const QByteArray& buffer);
/**
* @brief
*
* @param buffer
*/
void slot_verify_email_by_eml_data_result_helper(
const QMap<QString, QString>& p);
/**
* @brief
*
* @param result_analyse
*/
void slot_verifying_unknown_signature_helper(const QStringList& fprs);
/**
* @brief
*
* @param result_analyse
*/
void slot_result_analyse_show_helper(const GpgResultAnalyse& r);
/**
* @brief
*
* @param r_a
* @param r_b
*/
void slot_result_analyse_show_helper(const GpgResultAnalyse& r_a,
const GpgResultAnalyse& r_b);
/**
* @brief
*
* @param opera_results
*/
void slot_result_analyse_show_helper(
const QContainer<GpgOperaResult>& opera_results);
/**
* @brief
*
* @param result_analyse
*/
void slot_eml_verify_show_helper(const QString& email_info,
const GpgVerifyResultAnalyse& r);
/**
* @brief
*
* @param status
* @param text
*/
void slot_refresh_info_board(int status, const QString& text);
/**
* @brief
*
*/
void slot_clean_gpg_password_cache(bool);
/**
* @brief
*
*/
void slot_reload_gpg_components(bool);
/**
* @brief
*
*/
void slot_restart_gpg_components(bool);
/**
* @brief
*
* @param buffer
*/
void slot_decrypt_email_by_eml_data(const QByteArray& buffer);
/**
* @brief
*
* @param results
*/
void slot_gpg_opera_buffer_show_helper(
const QContainer<GpgOperaResult>& results);
private:
/**
* @details Create actions for the main-menu and the context-menu of the
* keylist.
*/
void create_actions();
/**
* @details create the menu of the main-window.
*/
void create_menus();
/**
* @details Create edit-, crypt- and key-toolbars.
*/
void create_tool_bars();
/**
* @details Create statusbar of mainwindow.
*/
void create_status_bar();
/**
* @details Create keylist- and attachment-dockwindows.
*/
void create_dock_windows();
/**
* @details Create attachment dock window.
*/
void create_attachment_dock();
/**
* @details close attachment-dockwindow.
*/
void close_attachment_dock();
/**
* @details Load settings from ini-file.
*/
void restore_settings();
/**
* @details
*/
void recover_editor_unsaved_pages_from_cache();
/**
* @brief Create a action object
*
* @param id
* @param name
* @param icon
* @param too_tip
* @return QAction*
*/
auto create_action(const QString& id, const QString& name,
const QString& icon, const QString& too_tip,
const QContainer<QKeySequence>& shortcuts = {})
-> QAction*;
/**
* @brief
*
*/
void decrypt_email_by_eml_data_result_helper(QMap<QString, QString> p);
/**
* @brief
*
* @param err_code
* @param error_string
* @return QString
*/
auto handle_module_error(QMap<QString, QString> p) -> bool;
/**
* @brief
*
* @param paths
* @return true
* @return false
*/
auto check_read_file_paths_helper(const QStringList& paths) -> bool;
/**
* @brief
*
* @param paths
* @return true
* @return false
*/
auto check_write_file_paths_helper(const QStringList& paths) -> bool;
/**
* @brief
*
* @param key_ids
* @param capability_check
* @param capability_err_string
* @return GpgKeyList
*/
auto check_keys_helper(
const KeyIdArgsList& key_ids,
const std::function<bool(const GpgKey&)>& capability_check,
const QString& capability_err_string) -> GpgKeyList;
/**
* @brief
*
* @param context
* @return auto
*/
void exec_operas_helper(
const QString& task,
const QSharedPointer<GpgOperaContextBasement>& contexts);
/**
* @brief
*
* @param contexts
* @param key_ids
* @param keys
* @return true
* @return false
*/
auto encrypt_operation_key_validate(
const QSharedPointer<GpgOperaContextBasement>& contexts) -> bool;
/**
* @brief
*
* @param contexts
* @return true
* @return false
*/
auto sign_operation_key_validate(
const QSharedPointer<GpgOperaContextBasement>& contexts) -> bool;
/**
* @brief
*
* @return auto
*/
void check_update_at_startup();
TextEdit* edit_{}; ///< Tabwidget holding the edit-windows
QMenu* file_menu_{}; ///< Submenu for file-operations
QMenu* edit_menu_{}; ///< Submenu for text-operations
QMenu* crypt_menu_{}; ///< Submenu for crypt-operations
QMenu* advance_menu_{}; ///< Submenu for help-operations
QMenu* help_menu_{}; ///< Submenu for help-operations
QMenu* key_menu_{}; ///< Submenu for key-operations
QMenu* view_menu_{}; ///< Submenu for view operations
QMenu* import_key_menu_{}; ///< Submenu for import operations
QToolBar* crypt_tool_bar_{}; ///< Toolbar holding crypt actions
QToolBar* file_tool_bar_{}; ///< Toolbar holding file actions
QToolBar* edit_tool_bar_{}; ///< Toolbar holding edit actions
QToolBar*
special_edit_tool_bar_{}; ///< Toolbar holding special edit actions
QToolBar* key_tool_bar_{}; ///< Toolbar holding key operations
QToolButton*
import_button_{}; ///< Tool button for import dropdown menu in toolbar
QDockWidget* key_list_dock_{}; ///< Encrypt Dock
QDockWidget* attachment_dock_{}; ///< Attachment Dock
QDockWidget* info_board_dock_{};
QAction* new_tab_act_{}; ///< Action to create new tab
QAction* new_email_tab_act_{}; ///< Action to create email tab
QAction* switch_tab_up_act_{}; ///< Action to switch tab up
QAction* switch_tab_down_act_{}; ///< Action to switch tab down
QAction* open_act_{}; ///< Action to open file
QAction* browser_act_{}; ///< Action to open file browser
QAction* save_act_{}; ///< Action to save file
QAction* save_as_act_{}; ///< Action to save file as
QAction* print_act_{}; ///< Action to print
QAction* close_tab_act_{}; ///< Action to print
QAction* quit_act_{}; ///< Action to quit application
QAction* encrypt_act_{}; ///< Action to encrypt text
QAction* encrypt_sign_act_{}; ///< Action to encrypt and sign text
QAction* decrypt_verify_act_{}; ///< Action to encrypt and sign text
QAction* decrypt_act_{}; ///< Action to decrypt text
QAction* sign_act_{}; ///< Action to sign text
QAction* verify_act_{}; ///< Action to verify text
QAction* import_key_from_edit_act_{}; ///< Action to import key from edit
QAction* clean_double_line_breaks_act_{}; ///< Action to remove double
///< line breaks
QAction* gnupg_controller_open_act_{}; ///<
QAction* module_controller_open_act_{}; ///<
QAction* smart_card_controller_open_act_{}; ///<
QAction* clean_gpg_password_cache_act_{}; ///<
QAction* reload_components_act_{}; ///<
QAction* restart_components_act_{}; ///<
QAction* append_selected_keys_act_{}; ///< Action to append selected keys
///< to edit
QAction* append_key_fingerprint_to_editor_act_{}; ///<
QAction* append_key_create_date_to_editor_act_{}; ///<
QAction* append_key_expire_date_to_editor_act_{}; ///<
QAction* copy_mail_address_to_clipboard_act_{}; ///< Action to copy mail to
///< clipboard
QAction* copy_key_id_to_clipboard_act_{}; ///<
QAction* copy_key_default_uid_to_clipboard_act_{}; ///<
QAction* add_key_2_favourite_act_{}; ///<
QAction* remove_key_from_favourtie_act_{}; ///<
QAction* set_owner_trust_of_key_act_{}; ///<
QAction* open_key_management_act_{}; ///< Action to open key management
QAction* copy_act_{}; ///< Action to copy text
QAction* quote_act_{}; ///< Action to quote text
QAction* cut_act_{}; ///< Action to cut text
QAction* paste_act_{}; ///< Action to paste text
QAction* select_all_act_{}; ///< Action to select whole text
QAction* find_act_{}; ///< Action to find text
QAction* undo_act_{}; ///< Action to undo last action
QAction* redo_act_{}; ///< Action to redo last action
QAction* zoom_in_act_{}; ///< Action to zoom in
QAction* zoom_out_act_{}; ///< Action to zoom out
QAction* about_act_{}; ///< Action to open about dialog
QAction* check_update_act_{}; ///< Action to open about dialog
QAction* translate_act_{}; ///< Action to open about dialog
QAction* gnupg_act_{}; ///< Action to open about dialog
QAction* open_settings_act_{}; ///< Action to open settings dialog
QAction* show_key_details_act_{}; ///< Action to open key-details dialog
QAction* start_wizard_act_{}; ///< Action to open the wizard
QAction* cut_pgp_header_act_{}; ///< Action for cutting the PGP header
QAction* add_pgp_header_act_{}; ///< Action for adding the PGP header
QAction* import_key_from_file_act_{}; ///<
QAction* import_key_from_clipboard_act_{}; ///<
QAction* import_key_from_key_server_act_{}; ///<
QLabel* status_bar_icon_{}; ///<
KeyList* m_key_list_{}; ///<
InfoBoardWidget* info_board_{}; ///<
QMap<QString, QPointer<QAction>> buffered_actions_;
bool attachment_dock_created_{}; ///<
int restart_mode_{0}; ///<
bool prohibit_update_checking_ = false; ///<
};
} // namespace GpgFrontend::UI
|