Dooble
dooble.h
1 /*
2 ** Copyright (c) 2008 - present, Alexis Megas.
3 ** All rights reserved.
4 **
5 ** Redistribution and use in source and binary forms, with or without
6 ** modification, are permitted provided that the following conditions
7 ** are met:
8 ** 1. Redistributions of source code must retain the above copyright
9 ** notice, this list of conditions and the following disclaimer.
10 ** 2. Redistributions in binary form must reproduce the above copyright
11 ** notice, this list of conditions and the following disclaimer in the
12 ** documentation and/or other materials provided with the distribution.
13 ** 3. The name of the author may not be used to endorse or promote products
14 ** derived from Dooble without specific prior written permission.
15 **
16 ** DOOBLE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 ** DOOBLE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef dooble_h
29 #define dooble_h
30 
31 #include <QFuture>
32 #include <QMainWindow>
33 #include <QShortcut>
34 #include <QPointer>
35 #include <QPrinter>
36 #include <QTimer>
37 #include <QWebEngineCookieStore>
38 
39 #include "dooble_settings.h"
40 #include "ui_dooble.h"
41 #include "ui_dooble_floating_digital_clock.h"
42 
43 #ifdef DOOBLE_PEEKABOO
44 extern "C"
45 {
46 #include <gpgme.h>
47 }
48 #endif
49 
50 class QDialog;
51 class QPrinter;
52 class QWebEngineDownloadItem;
53 class QWebEngineProfile;
54 class dooble_about;
56 class dooble_application;
58 class dooble_charts;
59 class dooble_cookies;
62 class dooble_downloads;
64 class dooble_gopher;
65 class dooble_history;
67 class dooble_page;
68 class dooble_popup_menu;
70 class dooble_style_sheet;
73 
74 class dooble: public QMainWindow
75 {
76  Q_OBJECT
77 
78  public:
79  enum Limits
80  {
81  MAXIMUM_TITLE_LENGTH = 1024,
82  MAXIMUM_SQL_TEXT_LENGTH = 5000,
83  MAXIMUM_URL_LENGTH = 2048
84  };
85 
86  dooble(QWidget *widget);
87  dooble(const QList<QUrl> &urls, bool is_private);
88  dooble(dooble_page *page);
90  ~dooble();
91  bool anonymous_tab_headers(void) const;
92  bool initialized(void) const;
93  bool is_private(void) const;
94  dooble_page *current_page(void) const;
95  dooble_page *new_page(const QUrl &url, bool is_private);
96  static QPointer<dooble_about> s_about;
97  static QPointer<dooble_accepted_or_blocked_domains>
98  s_accepted_or_blocked_domains;
99  static QPointer<dooble_application> s_application;
100  static QPointer<dooble_certificate_exceptions> s_certificate_exceptions;
101  static QPointer<dooble_cookies> s_cookies;
102  static QPointer<dooble_cookies_window> s_cookies_window;
103  static QPointer<dooble_cryptography> s_cryptography;
104  static QPointer<dooble_downloads> s_downloads;
105  static QPointer<dooble_favorites_popup> s_favorites_window;
106  static QPointer<dooble_gopher> s_gopher;
107  static QPointer<dooble_history> s_history;
108  static QPointer<dooble_history_window> s_history_popup;
109  static QPointer<dooble_history_window> s_history_window;
110  static QPointer<dooble_search_engines_popup> s_search_engines_window;
111  static QPointer<dooble_settings> s_settings;
112  static QPointer<dooble_style_sheet> s_style_sheet;
113  static QPointer<dooble_web_engine_url_request_interceptor>
114  s_url_request_interceptor;
115  static QString ABOUT_BLANK;
116  static QString s_default_http_user_agent;
117  static void clean(void);
118  static void print(QWidget *parent, dooble_charts *chart);
119  static void print_preview(QPrinter *printer, dooble_charts *chart);
120  void print_current_page(void);
121 
122  public slots:
123  void show(void);
124 
125  protected:
126  void closeEvent(QCloseEvent *event);
127  void keyPressEvent(QKeyEvent *event);
128 
129  private:
130  enum CanExit
131  {
132  CAN_EXIT_CLOSE_EVENT = 0,
133  CAN_EXIT_SLOT_QUIT_DOOBLE
134  };
135 
136  QDialog *m_floating_digital_clock_dialog;
137  QEventLoop m_event_loop;
138  QFuture<QList<QByteArray> > m_pbkdf2_future;
139  QFutureWatcher<QList<QByteArray> > m_pbkdf2_future_watcher;
140 #ifdef Q_OS_MACOS
141  QHash<QTimer *, QShortcut *> m_disabled_shortcuts;
142 #endif
143  QList<QPair<QPointer<dooble_page>, QUrl> > m_delayed_pages;
144  QList<QPointer<QAction> > m_standard_menu_actions;
145  QList<QShortcut *> m_shortcuts;
146  QList<QShortcut *> m_tab_widget_shortcuts;
147  QList<QUrl> all_open_tab_urls(void) const;
148  QMenu *m_menu;
149  QPointer<QAction> m_action_close_tab;
150  QPointer<QAction> m_authentication_action;
151  QPointer<QAction> m_full_screen_action;
152  QPointer<QAction> m_settings_action;
153  QPointer<QProgressDialog> m_pbkdf2_dialog;
154  QPointer<QWebEngineProfile> m_web_engine_profile;
155  QPointer<dooble_cookies> m_cookies;
156  QPointer<dooble_cookies_window> m_cookies_window;
157  QPointer<dooble_downloads> m_downloads;
158  QPointer<dooble_popup_menu> m_popup_menu;
159  QPrinter m_printer;
160  QTimer m_floating_digital_clock_timer;
161  QTimer m_populate_containers_timer;
162  Ui_dooble m_ui;
163  Ui_dooble_floating_digital_clock m_floating_digital_clock_ui;
164  bool m_anonymous_tab_headers;
165  bool m_is_javascript_dialog;
166  bool m_is_private;
167  bool m_print_preview;
168  static QPointer<dooble> s_dooble;
169  static QPointer<dooble> s_favorites_popup_opened_from_dooble_window;
170  static QPointer<dooble> s_search_engines_popup_opened_from_dooble_window;
171  static bool s_containers_populated;
172  QStringList chart_names(void) const;
173  bool can_exit(const dooble::CanExit can_exit);
174  bool tabs_closable(void) const;
175  static bool cookie_filter
176  (const QWebEngineCookieStore::FilterRequest &filter_request);
177 #ifdef DOOBLE_PEEKABOO
178  static gpgme_error_t peekaboo_passphrase(void *hook,
179  const char *uid_hint,
180  const char *passphrase_info,
181  int prev_was_bad,
182  int fd);
183 #endif
184  void add_tab(QWidget *widget, const QString &title);
185  void connect_signals(void);
186  void decouple_support_windows(void);
187  void delayed_load(const QUrl &url, dooble_page *page);
188  void initialize_static_members(void);
189  void new_page(dooble_charts *chart);
190  void new_page(dooble_page *page);
191  void new_page(dooble_web_engine_view *view);
192  void open_tab_as_new_window(bool is_private, int index);
193  void prepare_control_w_shortcut(void);
194  void prepare_icons(void);
195  void prepare_page_connections(dooble_page *page);
196  void prepare_private_web_engine_profile_settings(void);
197  void prepare_shortcuts(void);
198  void prepare_standard_menus(void);
199  void prepare_style_sheets(void);
200  void prepare_tab_icons_text_tool_tips(void);
201  void prepare_tab_shortcuts(void);
202  void print(dooble_page *page);
203  void remove_page_connections(dooble_page *page);
204  void setWindowTitle(const QString &text);
205 
206  private slots:
207  void slot_about_to_hide_main_menu(void);
208  void slot_about_to_show_history_menu();
209  void slot_about_to_show_main_menu(void);
210  void slot_about_to_show_tabs_menu(void);
211  void slot_about_to_show_view_menu(void);
212  void slot_anonymous_tab_headers(bool state);
213  void slot_application_locked(bool state, dooble *d);
214  void slot_authenticate(void);
215  void slot_clear_downloads(void);
216  void slot_clear_history(void);
217  void slot_clear_visited_links(void);
218  void slot_close_tab(void);
219  void slot_create_dialog(dooble_web_engine_view *view);
220  void slot_create_tab(dooble_web_engine_view *view);
221  void slot_create_window(dooble_web_engine_view *view);
222  void slot_decouple_tab(int index);
223  void slot_dooble_credentials_authenticated(bool state);
224  void slot_dooble_credentials_created(void);
225  void slot_downloads_started(void);
226 #ifdef Q_OS_MACOS
227  void slot_enable_shortcut(void);
228 #endif
229  void slot_export_as_png(void);
230  void slot_floating_digital_dialog_timeout(void);
231  void slot_history_action_triggered(void);
232  void slot_history_favorites_populated(void);
233  void slot_icon_changed(const QIcon &icon);
234  void slot_inject_custom_css(void);
235  void slot_load_finished(bool ok);
236  void slot_new_private_window(void);
237  void slot_new_tab(const QUrl &url);
238  void slot_new_tab(void);
239  void slot_new_window(void);
240  void slot_open_chart(void);
241  void slot_open_favorites_link(const QUrl &url);
242  void slot_open_favorites_link_in_new_tab(const QUrl &url);
243  void slot_open_link(const QUrl &url);
244  void slot_open_link_in_new_private_window(const QUrl &url);
245  void slot_open_link_in_new_tab(const QUrl &url);
246  void slot_open_link_in_new_window(const QUrl &url);
247  void slot_open_local_file(void);
248  void slot_open_previous_session_tabs(void);
249  void slot_open_tab_as_new_private_window(int index);
250  void slot_open_tab_as_new_window(int index);
251  void slot_pbkdf2_future_finished(void);
252  void slot_peekaboo_text(const QString &t);
253  void slot_populate_containers_timer_timeout(void);
254  void slot_populated(void);
255  void slot_print(void);
256  void slot_print_finished(bool ok);
257  void slot_print_preview(QPrinter *printer);
258  void slot_print_preview(void);
259  void slot_quit_dooble(void);
260  void slot_reload_tab(int index);
261  void slot_reload_tab_periodically(int index, int seconds);
262  void slot_remove_tab_widget_shortcut(void);
263  void slot_save(void);
264  void slot_set_current_tab(void);
265  void slot_settings_applied(void);
266 #ifdef Q_OS_MACOS
267  void slot_shortcut_activated(void);
268 #endif
269  void slot_show_about(void);
270  void slot_show_accepted_or_blocked_domains(void);
271  void slot_show_certificate_exceptions(void);
272  void slot_show_chart_xyseries(void);
273  void slot_show_clear_items(void);
274  void slot_show_cookies(void);
275  void slot_show_documentation(void);
276  void slot_show_downloads(void);
277  void slot_show_favorites(void);
278  void slot_show_floating_digital_clock(void);
279  void slot_show_floating_history_popup(void);
280  void slot_show_floating_menu(void);
281  void slot_show_full_screen(bool state);
282  void slot_show_full_screen(void);
283  void slot_show_history(void);
284  void slot_show_main_menu(void);
285  void slot_show_release_notes(const QUrl &url);
286  void slot_show_release_notes(void);
287  void slot_show_search_engines(void);
288  void slot_show_settings(void);
289  void slot_show_settings_panel(dooble_settings::Panels panel);
290  void slot_show_site_cookies(void);
291  void slot_tab_close_requested(int index);
292  void slot_tab_index_changed(int index);
293  void slot_tab_widget_shortcut_activated(void);
294  void slot_tabs_menu_button_clicked(void);
295  void slot_title_changed(const QString &title);
296  void slot_vacuum_databases(void);
297  void slot_warn_of_missing_sqlite_driver(void);
298  void slot_window_close_requested(void);
299 
300  signals:
301  void add_session_url(void);
302  void application_locked(bool state, dooble *d);
303  void dooble_credentials_authenticated(bool state);
304  void history_cleared(void);
305 };
306 
307 #endif
Definition: dooble_about.h:136
Definition: dooble_accepted_or_blocked_domains.h:42
Definition: dooble_application.h:37
Definition: dooble_certificate_exceptions.h:37
Definition: dooble_charts.h:49
Definition: dooble_cookies_window.h:42
Definition: dooble_cookies.h:36
Definition: dooble_cryptography.h:36
Definition: dooble_downloads.h:46
Definition: dooble_favorites_popup.h:37
Definition: dooble_gopher.h:41
Definition: dooble_history_window.h:38
Definition: dooble_history.h:46
Definition: dooble_page.h:50
Definition: dooble_popup_menu.h:38
Definition: dooble_search_engines_popup.h:42
Definition: dooble_style_sheet.h:38
Definition: dooble_web_engine_url_request_interceptor.h:36
Definition: dooble_web_engine_view.h:37
Definition: dooble.h:75