diff options
author | Antenore Gatta <antenore@simbiosi.org> | 2022-11-11 16:04:51 +0300 |
---|---|---|
committer | Antenore Gatta <antenore@simbiosi.org> | 2022-11-11 16:04:51 +0300 |
commit | dd63c22a4aeb302e604368677903ae2b6ac67715 (patch) | |
tree | 6e7a69e0fb6df4bb494e971609df0e75108e49ab | |
parent | 87fa700ca921853e52da01afb0590d3aa956293e (diff) |
Removing the News Widget
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | config.h.in | 1 | ||||
-rw-r--r-- | data/ui/remmina_main.glade | 10 | ||||
-rw-r--r-- | data/ui/remmina_preferences.glade | 57 | ||||
-rw-r--r-- | flatpak/org.remmina.Remmina-local.json | 1 | ||||
-rw-r--r-- | flatpak/org.remmina.Remmina.json | 1 | ||||
-rw-r--r-- | snap/snapcraft.yaml | 2 | ||||
-rw-r--r-- | src/CMakeLists.txt | 10 | ||||
-rw-r--r-- | src/remmina.1 | 5 | ||||
-rw-r--r-- | src/remmina.c | 9 | ||||
-rw-r--r-- | src/remmina.scd | 3 | ||||
-rw-r--r-- | src/remmina_main.c | 11 | ||||
-rw-r--r-- | src/remmina_main.h | 1 | ||||
-rw-r--r-- | src/remmina_pref.c | 36 | ||||
-rw-r--r-- | src/remmina_pref.h | 5 | ||||
-rw-r--r-- | src/remmina_pref_dialog.c | 7 | ||||
-rw-r--r-- | src/remmina_pref_dialog.h | 1 | ||||
-rw-r--r-- | src/rmnews.c | 671 | ||||
-rw-r--r-- | src/rmnews.h | 58 |
19 files changed, 5 insertions, 894 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8336db79e..2da909f28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -495,16 +495,6 @@ if(WITH_TRACE_CALLS) add_definitions(-DWITH_TRACE_CALLS) endif() -option(WITH_NEWS "Disable online version checking" ON) -if(WITH_NEWS) - message(STATUS "Enabling version check connecting to remmina.org") - add_definitions(-DWITH_NEWS) - set(RMNEWS_ENABLE_NEWS 1) -else() - message(STATUS "Disabling version check connecting to remmina.org") - set(RMNEWS_ENABLE_NEWS 0) -endif() - option(WITH_MANPAGES "Build with MANPAGES" ON) if(WITH_MANPAGES) message(STATUS "Enabling man pages.") diff --git a/config.h.in b/config.h.in index 077f1339c..0a22836dc 100644 --- a/config.h.in +++ b/config.h.in @@ -16,7 +16,6 @@ #define REMMINA_APP_ID "${REMMINA_APP_ID}" #define VERSION "${Remmina_VERSION}" #define REMMINA_GIT_REVISION "${REMMINA_GIT_REVISION}" -#define RMNEWS_ENABLE_NEWS ${RMNEWS_ENABLE_NEWS} #define GETTEXT_PACKAGE remmina diff --git a/data/ui/remmina_main.glade b/data/ui/remmina_main.glade index c0f90f89f..609cd80eb 100644 --- a/data/ui/remmina_main.glade +++ b/data/ui/remmina_main.glade @@ -330,16 +330,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. </object> </child> <child> - <object class="GtkMenuItem" id="menuitem_help_news"> - <property name="visible">True</property> - <property name="app-paintable">True</property> - <property name="can-focus">False</property> - <property name="action-name">app.news</property> - <property name="label" translatable="yes">News</property> - <property name="use-underline">True</property> - </object> - </child> - <child> <object class="GtkMenuItem" id="menuitem_help_homepage"> <property name="visible">True</property> <property name="app-paintable">True</property> diff --git a/data/ui/remmina_preferences.glade b/data/ui/remmina_preferences.glade index 6be3f20ab..71fe2ef60 100644 --- a/data/ui/remmina_preferences.glade +++ b/data/ui/remmina_preferences.glade @@ -389,7 +389,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">12</property> + <property name="top-attach">11</property> </packing> </child> <child> @@ -402,58 +402,11 @@ </object> <packing> <property name="left-attach">1</property> - <property name="top-attach">12</property> - <property name="width">2</property> - </packing> - </child> - <child> - <object class="GtkSwitch" id="switch_permit_news"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="halign">start</property> - <property name="valign">center</property> - <property name="margin-end">18</property> - </object> - <packing> - <property name="left-attach">1</property> <property name="top-attach">11</property> <property name="width">2</property> </packing> </child> <child> - <object class="GtkLabel" id="privacy_disclaimer_label"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">start</property> - <property name="margin-start">18</property> - <property name="margin-end">18</property> - <property name="label" translatable="yes">* By enabling news you consent to fetch data from remmina.org</property> - <property name="justify">fill</property> - <property name="wrap">True</property> - <property name="wrap-mode">word-char</property> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">14</property> - <property name="width">3</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="rmnews_allow_news_label"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="halign">start</property> - <property name="margin-start">18</property> - <property name="margin-end">6</property> - <property name="label" translatable="yes" comments="The star (*) is a reference to privacy consent">Fetch news from <a href="https://remmina.org" title="Remmina news site">remmina.org</a> (*)</property> - <property name="use-markup">True</property> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">11</property> - </packing> - </child> - <child> <object class="GtkEntry" id="entry_options_recent_items"> <property name="visible">True</property> <property name="can-focus">True</property> @@ -497,7 +450,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">13</property> + <property name="top-attach">12</property> </packing> </child> <child> @@ -511,7 +464,7 @@ </object> <packing> <property name="left-attach">1</property> - <property name="top-attach">13</property> + <property name="top-attach">12</property> <property name="width">2</property> </packing> </child> @@ -2378,7 +2331,7 @@ Except the "Weak" method, all the others are recommended, "Keystore" is the defa </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">12</property> + <property name="top-attach">11</property> </packing> </child> <child> @@ -2393,7 +2346,7 @@ Except the "Weak" method, all the others are recommended, "Keystore" is the defa </object> <packing> <property name="left-attach">1</property> - <property name="top-attach">12</property> + <property name="top-attach">11</property> <property name="width">8</property> </packing> </child> diff --git a/flatpak/org.remmina.Remmina-local.json b/flatpak/org.remmina.Remmina-local.json index b2da8f60f..e30c1cc9a 100644 --- a/flatpak/org.remmina.Remmina-local.json +++ b/flatpak/org.remmina.Remmina-local.json @@ -510,7 +510,6 @@ ], "config-opts": [ "-DCMAKE_BUILD_TYPE:STRING=Debug", - "-DWITH_NEWS:BOOL=ON", "-DCMAKE_INSTALL_LIBDIR:PATH=lib", "-DWITH_FREERDP3:BOOL=OFF", "-DWITH_GVNC:BOOL=ON", diff --git a/flatpak/org.remmina.Remmina.json b/flatpak/org.remmina.Remmina.json index 756d3fae4..331751113 100644 --- a/flatpak/org.remmina.Remmina.json +++ b/flatpak/org.remmina.Remmina.json @@ -510,7 +510,6 @@ ], "config-opts": [ "-DCMAKE_BUILD_TYPE:STRING=Release", - "-DWITH_NEWS:BOOL=ON", "-DCMAKE_INSTALL_LIBDIR:PATH=lib", "-DWITH_FREERDP3:BOOL=OFF", "-DWITH_GVNC:BOOL=ON", diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 71a0dac00..e9e9a2700 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -183,7 +183,6 @@ parts: - libjson-glib-dev - libkf5wallet-dev - libsodium-dev - - libsoup2.4-dev - libspice-client-gtk-3.0-dev - libspice-protocol-dev - libssh-dev @@ -225,7 +224,6 @@ parts: - xterm cmake-parameters: - -DCMAKE_BUILD_TYPE=Release - - -DWITH_NEWS:BOOL=ON - -DWITH_FREERDP3=OFF - -DWITH_KF5WALLET=ON - -DWITH_GVNC=ON diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f9e880f7c..415ce23af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -117,8 +117,6 @@ list( "remmina_sysinfo.c" "rcw.c" "rcw.h" - "rmnews.c" - "rmnews.h" "remmina_mpchange.c" "remmina_mpchange.h" "remmina_scheduler.c" @@ -132,7 +130,6 @@ set(RESOURCE_LIST ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_key_chooser.glade ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_main.glade ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_mpc.glade - ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_news.glade ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_passwd.glade ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_preferences.glade ${CMAKE_CURRENT_SOURCE_DIR}/../data/ui/remmina_search.glade @@ -251,13 +248,6 @@ if(GTK3_FOUND) else() message(FATAL_ERROR "json-glib library not found") endif() - find_required_package(LIBSOUP) - if(LIBSOUP_FOUND) - include_directories(${LIBSOUP_INCLUDE_DIRS}) - target_link_libraries(remmina ${LIBSOUP_LIBRARIES}) - else() - message(FATAL_ERROR "libsoup 2.4 library not found") - endif() endif() find_required_package(PCRE2) diff --git a/src/remmina.1 b/src/remmina.1 index e64b78b8b..27fc5057a 100644 --- a/src/remmina.1 +++ b/src/remmina.1 @@ -146,11 +146,6 @@ Encrypt a password X display to use .PP .RE -\fB--disable-news\fR -.RS 4 -Disable news notification -.PP -.RE \fB--disable-toolbar\fR .RS 4 Disable toolbar diff --git a/src/remmina.c b/src/remmina.c index 2156bff30..5b59339f8 100644 --- a/src/remmina.c +++ b/src/remmina.c @@ -64,7 +64,6 @@ #include "remmina_ssh_plugin.h" #include "remmina_widget_pool.h" #include "remmina/remmina_trace_calls.h" -#include "rmnews.h" #ifdef HAVE_ERRNO_H #include <errno.h> @@ -84,7 +83,6 @@ static int gcrypt_thread_initialized = 0; #endif /* HAVE_LIBGCRYPT */ gboolean kioskmode; -gboolean disablenews; gboolean disabletoolbar; gboolean fullscreen; gboolean extrahardening; @@ -129,7 +127,6 @@ static GOptionEntry remmina_options[] = // TRANSLATORS: Shown in terminal. Do not use characters that may be not supported on a terminal { "set-option", 0, 0, G_OPTION_ARG_STRING_ARRAY, NULL, N_("Set one or more profile settings, to be used with --update-profile"), NULL }, { "encrypt-password", 0, 0, G_OPTION_ARG_NONE, NULL, N_("Encrypt a password"), NULL }, - { "disable-news", 0, 0, G_OPTION_ARG_NONE, NULL, N_("Disable news notification"), NULL }, { "disable-toolbar", 0, 0, G_OPTION_ARG_NONE, NULL, N_("Disable toolbar"), NULL }, { "enable-fullscreen", 0, 0, G_OPTION_ARG_NONE, NULL, N_("Enable fullscreen"), NULL }, { "enable-extra-hardening", 0, 0, G_OPTION_ARG_NONE, NULL, N_("Enable extra hardening (disable closing confirmation, disable unsafe shortcut keys, hide tabs, hide search bar)"), NULL }, @@ -167,10 +164,6 @@ static gint remmina_on_command_line(GApplication *app, GApplicationCommandLine * #endif opts = g_application_command_line_get_options_dict(cmdline); - if (g_variant_dict_lookup_value(opts, "disable-news", NULL)) { - disablenews = TRUE; - } - if (g_variant_dict_lookup_value(opts, "disable-toolbar", NULL)) { disabletoolbar = TRUE; } @@ -298,8 +291,6 @@ static void remmina_on_startup(GApplication *app) REMMINA_RUNTIME_DATADIR G_DIR_SEPARATOR_S "icons"); g_application_hold(app); - rmnews_schedule(); - /* Check for secret plugin and service initialization and show console warnings if * something is missing */ secret_plugin = remmina_plugin_manager_get_secret_plugin(); diff --git a/src/remmina.scd b/src/remmina.scd index 007bf381c..b397ae5a8 100644 --- a/src/remmina.scd +++ b/src/remmina.scd @@ -100,9 +100,6 @@ The filetype can be ".remmina" or one supported by a plugin capable of *--display=DISPLAY* X display to use -*--disable-news* - Disable news notification - *--disable-toolbar* Disable toolbar diff --git a/src/remmina_main.c b/src/remmina_main.c index 003576c44..1c53cebae 100644 --- a/src/remmina_main.c +++ b/src/remmina_main.c @@ -92,7 +92,6 @@ const gchar *supported_mime_types[] = { static GActionEntry app_actions[] = { { "about", remmina_main_on_action_application_about, NULL, NULL, NULL }, - { "news", remmina_main_on_action_application_news, NULL, NULL, NULL }, { "default", remmina_main_on_action_application_default, NULL, NULL, NULL }, { "mpchange", remmina_main_on_action_application_mpchange, NULL, NULL, NULL }, { "plugins", remmina_main_on_action_application_plugins, NULL, NULL, NULL }, @@ -1239,16 +1238,6 @@ void remmina_main_on_action_application_about(GSimpleAction *action, GVariant *p remmina_about_open(remminamain->window); }; -void remmina_main_on_action_application_news(GSimpleAction *action, GVariant *param, gpointer data) -{ - TRACE_CALL(__func__); - REMMINA_DEBUG("Setting news counters to 0"); - remmina_pref.periodic_rmnews_last_get = 0; - remmina_pref.periodic_rmnews_get_count = 0; - REMMINA_DEBUG("Saving preferences"); - remmina_pref_save(); -}; - static gboolean is_empty(const gchar *s) { if (s == NULL) diff --git a/src/remmina_main.h b/src/remmina_main.h index ebe26eabc..f57e65ac2 100644 --- a/src/remmina_main.h +++ b/src/remmina_main.h @@ -113,7 +113,6 @@ void remmina_main_save_before_destroy(void); void remmina_main_show_dialog(GtkMessageType msg, GtkButtonsType buttons, const gchar* message); void remmina_main_show_warning_dialog(const gchar *message); void remmina_main_on_action_application_about(GSimpleAction *action, GVariant *param, gpointer data); -void remmina_main_on_action_application_news(GSimpleAction *action, GVariant *param, gpointer data); void remmina_main_on_action_application_default(GSimpleAction *action, GVariant *param, gpointer data); void remmina_main_on_action_application_mpchange(GSimpleAction *action, GVariant *param, gpointer data); void remmina_main_on_action_application_plugins(GSimpleAction *action, GVariant *param, gpointer data); diff --git a/src/remmina_pref.c b/src/remmina_pref.c index b0cc6f568..e420bb1d8 100644 --- a/src/remmina_pref.c +++ b/src/remmina_pref.c @@ -734,35 +734,6 @@ void remmina_pref_init(void) remmina_pref_file_load_colors(gkeyfile, &remmina_pref.color_pref); - /** RMNEWS_ENABLE_NEWS is equal to 0 (FALSE) when compiled with -DWiTH_NEWS=OFF, - * otherwise is value is 1 (TRUE), that is the default value - */ - if (RMNEWS_ENABLE_NEWS == 0) - remmina_pref.periodic_news_permitted = RMNEWS_ENABLE_NEWS; - else if (g_key_file_has_key(gkeyfile, "remmina_news", "periodic_news_permitted", NULL)) - remmina_pref.periodic_news_permitted = g_key_file_get_boolean(gkeyfile, "remmina_news", "periodic_news_permitted", NULL); - else - remmina_pref.periodic_news_permitted = RMNEWS_ENABLE_NEWS; - - - if (g_key_file_has_key(gkeyfile, "remmina_news", "periodic_rmnews_last_get", NULL)) { - remmina_pref.periodic_rmnews_last_get = g_key_file_get_int64(gkeyfile, "remmina_news", "periodic_rmnews_last_get", NULL); - REMMINA_DEBUG ("periodic_rmnews_last_get set to %ld", remmina_pref.periodic_rmnews_last_get); - } else { - remmina_pref.periodic_rmnews_last_get = 0; - REMMINA_DEBUG ("periodic_rmnews_last_get set to 0"); - } - - if (g_key_file_has_key(gkeyfile, "remmina_news", "periodic_rmnews_get_count", NULL)) - remmina_pref.periodic_rmnews_get_count = g_key_file_get_int64(gkeyfile, "remmina_news", "periodic_rmnews_get_count", NULL); - else - remmina_pref.periodic_rmnews_get_count = 0; - - if (g_key_file_has_key(gkeyfile, "remmina_news", "periodic_rmnews_uuid_prefix", NULL)) - remmina_pref.periodic_rmnews_uuid_prefix = g_key_file_get_string(gkeyfile, "remmina_news", "periodic_rmnews_uuid_prefix", NULL); - else - remmina_pref.periodic_rmnews_uuid_prefix = NULL; - /* If we have a color scheme file, we switch to it, GIO will merge it in the * remmina.pref file */ if (g_file_test(remmina_colors_file, G_FILE_TEST_IS_REGULAR)) { @@ -928,13 +899,6 @@ gboolean remmina_pref_save(void) g_key_file_set_string(gkeyfile, "ssh_colors", "color14", remmina_pref.color_pref.color14 ? remmina_pref.color_pref.color14 : ""); g_key_file_set_string(gkeyfile, "ssh_colors", "color15", remmina_pref.color_pref.color15 ? remmina_pref.color_pref.color15 : ""); - g_key_file_set_boolean(gkeyfile, "remmina_news", "periodic_news_permitted", remmina_pref.periodic_news_permitted); - g_debug("(%s) - Setting periodic_rmnews_last_get to %ld", __func__, remmina_pref.periodic_rmnews_last_get); - g_key_file_set_int64(gkeyfile, "remmina_news", "periodic_rmnews_last_get", remmina_pref.periodic_rmnews_last_get); - g_key_file_set_integer(gkeyfile, "remmina_news", "periodic_rmnews_get_count", remmina_pref.periodic_rmnews_get_count); - g_key_file_set_string(gkeyfile, "remmina_news", "periodic_rmnews_uuid_prefix", - remmina_pref.periodic_rmnews_uuid_prefix ? remmina_pref.periodic_rmnews_uuid_prefix : ""); - /* Default settings */ g_key_file_set_string(gkeyfile, "remmina", "name", ""); g_key_file_set_integer(gkeyfile, "remmina", "ignore-tls-errors", 1); diff --git a/src/remmina_pref.h b/src/remmina_pref.h index 5631b1589..371ae5243 100644 --- a/src/remmina_pref.h +++ b/src/remmina_pref.h @@ -235,11 +235,6 @@ typedef struct _RemminaPref { /* Usage stats */ gchar * last_success; - /* Remmina news */ - gboolean periodic_news_permitted; - glong periodic_rmnews_last_get; - glong periodic_rmnews_get_count; - gchar * periodic_rmnews_uuid_prefix; } RemminaPref; #define DEFAULT_SSH_PARSECONFIG TRUE diff --git a/src/remmina_pref_dialog.c b/src/remmina_pref_dialog.c index 68f8809e1..5478692df 100644 --- a/src/remmina_pref_dialog.c +++ b/src/remmina_pref_dialog.c @@ -244,9 +244,6 @@ void remmina_pref_on_dialog_destroy(GtkWidget *widget, gpointer user_data) remmina_pref.hide_connection_toolbar = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(remmina_pref_dialog->checkbutton_appearance_hide_toolbar)); remmina_pref.hide_searchbar = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(remmina_pref_dialog->checkbutton_appearance_hide_searchbar)); - b = gtk_switch_get_active(GTK_SWITCH(remmina_pref_dialog->switch_permit_news)); - remmina_pref.periodic_news_permitted = b; - remmina_pref.default_action = gtk_combo_box_get_active(remmina_pref_dialog->comboboxtext_options_double_click); remmina_pref.default_mode = gtk_combo_box_get_active(remmina_pref_dialog->comboboxtext_appearance_view_mode); remmina_pref.tab_mode = gtk_combo_box_get_active(remmina_pref_dialog->comboboxtext_appearance_tab_interface); @@ -495,8 +492,6 @@ static void remmina_pref_dialog_init(void) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remmina_pref_dialog->checkbutton_appearance_hide_toolbar), remmina_pref.hide_connection_toolbar); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remmina_pref_dialog->checkbutton_appearance_hide_searchbar), remmina_pref.hide_searchbar); - gtk_switch_set_active(GTK_SWITCH(remmina_pref_dialog->switch_permit_news), remmina_pref.periodic_news_permitted); - g_snprintf(buf, sizeof(buf), "%i", remmina_pref.sshtunnel_port); gtk_entry_set_text(remmina_pref_dialog->entry_options_ssh_port, buf); g_snprintf(buf, sizeof(buf), "%i", remmina_pref.ssh_tcp_keepidle); @@ -725,8 +720,6 @@ GtkWidget *remmina_pref_dialog_new(gint default_tab, GtkWindow *parent) remmina_pref_dialog->checkbutton_appearance_show_notes = GTK_CHECK_BUTTON(GET_OBJECT("checkbutton_appearance_show_notes")); remmina_pref_dialog->checkbutton_appearance_hide_toolbar = GTK_CHECK_BUTTON(GET_OBJECT("checkbutton_appearance_hide_toolbar")); remmina_pref_dialog->checkbutton_appearance_hide_searchbar = GTK_CHECK_BUTTON(GET_OBJECT("checkbutton_appearance_hide_searchbar")); - remmina_pref_dialog->switch_permit_news = GTK_SWITCH(GET_OBJECT("switch_permit_news")); - gtk_widget_set_sensitive(GTK_WIDGET(remmina_pref_dialog->switch_permit_news), RMNEWS_ENABLE_NEWS); remmina_pref_dialog->comboboxtext_options_double_click = GTK_COMBO_BOX(GET_OBJECT("comboboxtext_options_double_click")); remmina_pref_dialog->comboboxtext_appearance_view_mode = GTK_COMBO_BOX(GET_OBJECT("comboboxtext_appearance_view_mode")); remmina_pref_dialog->comboboxtext_appearance_tab_interface = GTK_COMBO_BOX(GET_OBJECT("comboboxtext_appearance_tab_interface")); diff --git a/src/remmina_pref_dialog.h b/src/remmina_pref_dialog.h index 2b5d8a758..7ac42914d 100644 --- a/src/remmina_pref_dialog.h +++ b/src/remmina_pref_dialog.h @@ -69,7 +69,6 @@ typedef struct _RemminaPrefDialog { GtkCheckButton * checkbutton_appearance_show_notes; GtkCheckButton * checkbutton_appearance_hide_toolbar; GtkCheckButton * checkbutton_appearance_hide_searchbar; - GtkSwitch * switch_permit_news; GtkComboBox * comboboxtext_options_double_click; GtkComboBox * comboboxtext_appearance_view_mode; GtkComboBox * comboboxtext_appearance_tab_interface; diff --git a/src/rmnews.c b/src/rmnews.c deleted file mode 100644 index f44af8704..000000000 --- a/src/rmnews.c +++ /dev/null @@ -1,671 +0,0 @@ -/* - * Remmina - The GTK+ Remote Desktop Client - * Copyright (C) 2016-2022 Antenore Gatta, Giovanni Panozzo - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * In addition, as a special exception, the copyright holders give - * permission to link the code of portions of this program with the - * OpenSSL library under certain conditions as described in each - * individual source file, and distribute linked combinations - * including the two. - * You must obey the GNU General Public License in all respects - * for all of the code used other than OpenSSL. * If you modify - * file(s) with this exception, you may extend this exception to your - * version of the file(s), but you are not obligated to do so. * If you - * do not wish to do so, delete this exception statement from your - * version. * If you delete this exception statement from all source - * files in the program, then also delete it here. - * - */ - -#include "config.h" -#include "remmina/remmina_trace_calls.h" - -#include <fcntl.h> -#include <gio/gdesktopappinfo.h> -#include <gio/gio.h> -#include <glib/gi18n.h> -#include <glib/gstdio.h> -#include <libsoup/soup.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <time.h> - -#include "remmina.h" -#include "remmina_main.h" -#include "remmina_log.h" -#include "remmina_pref.h" -#include "remmina_public.h" -#include "remmina_sodium.h" -#include "remmina_utils.h" -#include "remmina_scheduler.h" -#include "remmina_sysinfo.h" -#include "rmnews.h" - -#define ARR_SIZE(arr) (sizeof((arr)) / sizeof((arr[0]))) -/* Neas file buffer */ -#define READ_BUFFER_LEN 1024 -/* Timers */ -#define RMNEWS_CHECK_1ST_MS 3000 -#define RMNEWS_CHECK_INTERVAL_MS 12000 -/* How many seconds before to get news */ -#define RMNEWS_INTERVAL_SEC 604800 -/* TODO: move in config.h */ -#define REMMINA_URL "https://remmina.org/" -#define RMNEWS_OUTPUT "/var/tmp/latest_news.md" - -static RemminaNewsDialog *rmnews_news_dialog; -#define GET_OBJ(object_name) gtk_builder_get_object(rmnews_news_dialog->builder, object_name) - -static SoupSession *session; - -#if SOUP_MAJOR_VERSION < 3 -#define soup_message_get_status(message) message->status_code -#define soup_message_get_response_headers(message) message->response_headers -#endif - -static const gchar *output_file_path = NULL; - -static -const gchar *supported_mime_types[] = { - "x-scheme-handler/rdp", - "x-scheme-handler/spice", - "x-scheme-handler/vnc", - "x-scheme-handler/remmina", - "application/x-remmina", - NULL -}; - -gint eweekdays[7] = { - 86400, - 172800, - 259200, - 345600, - 432000, - 518400, - 604800 -}; - - -#if SOUP_CHECK_VERSION (2, 99, 2) -static void rmnews_on_stream_splice (GObject *source, GAsyncResult *result, gpointer user_data) -{ - GError *error = NULL; - g_output_stream_splice_finish (G_OUTPUT_STREAM (source), - result, - &error); - if (error) { - g_printerr ("Failed to download: %s\n", error->message); - g_error_free (error); - return; - } - -} -#endif - -void rmnews_news_switch_state_set_cb() -{ - TRACE_CALL(__func__); - if (rmnews_news_dialog->rmnews_news_switch && \ - gtk_switch_get_active(rmnews_news_dialog->rmnews_news_switch)) { - remmina_pref.periodic_news_permitted = TRUE; - remmina_pref_save(); - } else { - remmina_pref.periodic_news_permitted = FALSE; - remmina_pref_save(); - } -} - -void rmnews_defaultcl_on_click() -{ - TRACE_CALL(__func__); - g_autoptr(GError) error = NULL; - GDesktopAppInfo *desktop_info; - GAppInfo *info = NULL; - g_autofree gchar *id = g_strconcat(REMMINA_APP_ID, ".desktop", NULL); - int i; - - desktop_info = g_desktop_app_info_new(id); - if (!desktop_info) - return; - - info = G_APP_INFO(desktop_info); - - for (i = 0; supported_mime_types[i]; i++) { - if (!g_app_info_set_as_default_for_type(info, supported_mime_types[i], &error)) - REMMINA_DEBUG("Failed to set '%s' as the default application for secondary content type '%s': %s", - g_app_info_get_name(info), supported_mime_types[i], error->message); - else - REMMINA_DEBUG("Set '%s' as the default application for '%s'", - g_app_info_get_name(info), - supported_mime_types[i]); - } -} - -static gchar *rmnews_get_file_contents(gchar *path) -{ - gsize size; - gchar *content; - - if (g_file_get_contents(path, &content, &size, NULL)) { - if (!g_utf8_validate(content, size, NULL)) { - REMMINA_DEBUG("%s content is not UTF-8", path); - g_free(content); - content = NULL; - } - } - //return g_markup_escape_text(content, strlen(content)); - return content; -} - -static void rmnews_close_clicked(GtkButton *btn, gpointer user_data) -{ - TRACE_CALL(__func__); - if (rmnews_news_dialog->dialog) - gtk_widget_destroy(GTK_WIDGET(rmnews_news_dialog->dialog)); - rmnews_news_dialog->dialog = NULL; - g_free(rmnews_news_dialog); - rmnews_news_dialog = NULL; -} - -static gboolean rmnews_dialog_deleted(GtkButton *btn, gpointer user_data) -{ - TRACE_CALL(__func__); - gtk_widget_destroy(GTK_WIDGET(rmnews_news_dialog->dialog)); - rmnews_news_dialog->dialog = NULL; - g_free(rmnews_news_dialog); - rmnews_news_dialog = NULL; - - return FALSE; -} - -void rmnews_show_news(GtkWindow *parent) -{ - TRACE_CALL(__func__); - - if (disablenews) return; - - rmnews_news_dialog = g_new0(RemminaNewsDialog, 1); - rmnews_news_dialog->retval = 1; - - rmnews_news_dialog->builder = remmina_public_gtk_builder_new_from_resource("/org/remmina/Remmina/src/../data/ui/remmina_news.glade"); - rmnews_news_dialog->dialog = GTK_DIALOG(gtk_builder_get_object(rmnews_news_dialog->builder, "RemminaNewsDialog")); - - rmnews_news_dialog->rmnews_text_view = GTK_TEXT_VIEW(GET_OBJ("rmnews_text_view")); - rmnews_news_dialog->rmnews_label = GTK_LABEL(GET_OBJ("rmnews_label")); - rmnews_news_dialog->rmnews_defaultcl_label = GTK_LABEL(GET_OBJ("rmnews_defaultcl_label")); - rmnews_news_dialog->rmnews_defaultcl_button = GTK_BUTTON(GET_OBJ("rmnews_defaultcl_switch")); - rmnews_news_dialog->rmnews_news_switch = GTK_SWITCH(GET_OBJ("rmnews_news_switch")); - if (remmina_pref.periodic_news_permitted == 1) - gtk_switch_set_active(rmnews_news_dialog->rmnews_news_switch, TRUE); - else - gtk_switch_set_active(rmnews_news_dialog->rmnews_news_switch, FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(rmnews_news_dialog->rmnews_news_switch), RMNEWS_ENABLE_NEWS); - - rmnews_news_dialog->rmnews_button_close = GTK_BUTTON(GET_OBJ("rmnews_button_close")); - gtk_widget_set_can_default(GTK_WIDGET(rmnews_news_dialog->rmnews_button_close), TRUE); - gtk_widget_grab_default(GTK_WIDGET(rmnews_news_dialog->rmnews_button_close)); - - if (remmina_pref.periodic_news_permitted == 1) { - gchar *contents = rmnews_get_file_contents(g_strdup(output_file_path)); - if (contents) { - gtk_label_set_markup(rmnews_news_dialog->rmnews_label, contents); - g_free(contents); - } - } - - g_signal_connect(rmnews_news_dialog->rmnews_button_close, "clicked", - G_CALLBACK(rmnews_close_clicked), (gpointer)rmnews_news_dialog); - g_signal_connect(rmnews_news_dialog->dialog, "close", - G_CALLBACK(rmnews_close_clicked), NULL); - g_signal_connect(rmnews_news_dialog->dialog, "delete-event", - G_CALLBACK(rmnews_dialog_deleted), NULL); - - /* Connect signals */ - gtk_builder_connect_signals(rmnews_news_dialog->builder, NULL); - - /* Show the non-modal news dialog */ - gtk_widget_show_all(GTK_WIDGET(rmnews_news_dialog->dialog)); - gtk_window_present(GTK_WINDOW(rmnews_news_dialog->dialog)); - if (parent) - gtk_window_set_transient_for(GTK_WINDOW(rmnews_news_dialog->dialog), parent); - gtk_window_set_modal(GTK_WINDOW(rmnews_news_dialog->dialog), TRUE); -} - -#if SOUP_CHECK_VERSION (2, 99, 2) -static void rmnews_get_url_cb (GObject *source, GAsyncResult *result, gpointer user_data) -{ - TRACE_CALL(__func__); - const char *name; - const char *header; - GFile *output_file; - gchar *filesha = NULL; - gchar *filesha_after = NULL; - - GError *error = NULL; - GInputStream *in = soup_session_send_finish (SOUP_SESSION (source), result, &error); - - if (error) { - REMMINA_DEBUG ("Failed to send request: %s", error->message); - g_error_free (error); - return; - } - - GDateTime *gdt = g_date_time_new_now_utc(); - gint64 unixts = g_date_time_to_unix(gdt); - g_date_time_unref(gdt); - - if (output_file_path) { - REMMINA_DEBUG("Calculating the SHA1 of the local file"); - filesha = remmina_sha1_file(output_file_path); - REMMINA_DEBUG("SHA1 is %s", filesha); - if (filesha == NULL || filesha[0] == 0) filesha = "0\0"; - REMMINA_DEBUG("Opening %s output file for writing", output_file_path); - GFile *output_file = g_file_new_for_commandline_arg (output_file_path); - GOutputStream *out = G_OUTPUT_STREAM (g_file_replace (output_file, NULL, NULL, - G_FILE_CREATE_REPLACE_DESTINATION, NULL, &error)); - if (error) { - REMMINA_DEBUG("Failed to create \"%s\": %s", output_file_path, error->message); - remmina_pref.periodic_rmnews_last_get = unixts; - REMMINA_DEBUG ("periodic_rmnews_last_get set to %ld", remmina_pref.periodic_rmnews_last_get); - REMMINA_DEBUG ("Saving preferences"); - remmina_pref_save(); - g_free(filesha); filesha = NULL; - g_error_free (error); - g_object_unref (in); - g_object_unref (output_file); - g_object_unref (out); - return; - } - - /* Start downloading to the file */ - // g_output_stream_splice_async (G_OUTPUT_STREAM (out), in, - // G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, - // G_PRIORITY_DEFAULT, - // NULL, - // rmnews_on_stream_splice, - // NULL); - g_output_stream_splice (G_OUTPUT_STREAM (out), in, - G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, - NULL, - &error); - - if (error) { - REMMINA_DEBUG ("Failed to download: %s", error->message); - remmina_pref.periodic_rmnews_last_get = unixts; - REMMINA_DEBUG ("periodic_rmnews_last_get set to %ld", remmina_pref.periodic_rmnews_last_get); - REMMINA_DEBUG ("Saving preferences"); - remmina_pref_save(); - g_free(filesha); filesha = NULL; - g_error_free (error); - g_object_unref (in); - g_object_unref (output_file); - g_object_unref (out); - return; - } - - - filesha_after = remmina_sha1_file(output_file_path); - - REMMINA_DEBUG("SHA1 after download is %s", filesha_after); - if (g_strcmp0(filesha, filesha_after) != 0) { - REMMINA_DEBUG("SHA1 differs, we show the news and reset the counter"); - remmina_pref.periodic_rmnews_last_get = 0; - REMMINA_DEBUG ("periodic_rmnews_last_get set to %ld", remmina_pref.periodic_rmnews_last_get); - REMMINA_DEBUG ("Saving preferences"); - GtkWindow *parent = remmina_main_get_window(); - if (!kioskmode && kioskmode == FALSE) - rmnews_show_news(parent); - } else { - remmina_pref.periodic_rmnews_last_get = unixts; - } - /* Increase counter with number of successful GETs */ - remmina_pref.periodic_rmnews_get_count = remmina_pref.periodic_rmnews_get_count + 1; - remmina_pref_save(); - g_free(filesha); filesha = NULL; - g_object_unref (out); - } else { - REMMINA_DEBUG("Cannot open output file for writing, because output_file_path is NULL"); - remmina_pref.periodic_rmnews_last_get = unixts; - REMMINA_DEBUG ("periodic_rmnews_last_get set to %ld", remmina_pref.periodic_rmnews_last_get); - REMMINA_DEBUG ("Saving preferences"); - remmina_pref_save(); - return; - } - - g_object_unref (in); - - -} -#else -static void rmnews_get_url_cb(SoupSession *session, SoupMessage *msg, gpointer data) -{ - TRACE_CALL(__func__); - const char *name; - const char *header; - g_autoptr(SoupBuffer) sb; - FILE *output_file = NULL; - gchar *filesha = NULL; - gchar *filesha_after = NULL; - GDateTime *gdt; - gint64 unixts; - gint status; - - status = soup_message_get_status(msg); - REMMINA_DEBUG("Status code %d", status); - - name = soup_message_get_uri(msg)->path; - - gdt = g_date_time_new_now_utc(); - unixts = g_date_time_to_unix(gdt); - g_date_time_unref(gdt); - - if (SOUP_STATUS_IS_REDIRECTION(status)) { - header = soup_message_headers_get_one(soup_message_get_response_headers(msg), - "Location"); - REMMINA_DEBUG("Redirection detected"); - if (header) { - SoupURI *uri; - char *uri_string; - - REMMINA_DEBUG(" -> %s\n", header); - - uri = soup_uri_new_with_base(soup_message_get_uri(msg), header); - uri_string = soup_uri_to_string(uri, FALSE); - rmnews_get_url(uri_string); - g_free(uri_string); - soup_uri_free(uri); - } - remmina_pref.periodic_rmnews_last_get = unixts; - REMMINA_DEBUG ("periodic_rmnews_last_get set to %ld", remmina_pref.periodic_rmnews_last_get); - REMMINA_DEBUG ("Saving preferences"); - remmina_pref_save(); - return; - } - - if (!SOUP_STATUS_IS_SUCCESSFUL(status)) { - REMMINA_DEBUG ("Could not access %s: %s", name , soup_status_get_phrase(status)); - REMMINA_DEBUG ("periodic_rmnews_last_get set to %ld", remmina_pref.periodic_rmnews_last_get); - REMMINA_DEBUG ("Saving preferences"); - remmina_pref_save(); - return; - } else { - REMMINA_DEBUG("Status 200"); - if (output_file_path) { - REMMINA_DEBUG("Calculating the SHA1 of the local file"); - filesha = remmina_sha1_file(output_file_path); - REMMINA_DEBUG("SHA1 is %s", filesha); - if (filesha == NULL || filesha[0] == 0) filesha = "0\0"; - REMMINA_DEBUG("Opening %s output file for writing", output_file_path); - output_file = fopen(output_file_path, "w"); - if (!output_file) { - REMMINA_DEBUG("Error trying to create file %s.", output_file_path); - remmina_pref.periodic_rmnews_last_get = unixts; - REMMINA_DEBUG ("periodic_rmnews_last_get set to %ld", remmina_pref.periodic_rmnews_last_get); - REMMINA_DEBUG ("Saving preferences"); - remmina_pref_save(); - g_free(filesha); filesha = NULL; - return; - } - } else { - REMMINA_DEBUG("Cannot open output file for writing, because output_file_path is NULL"); - remmina_pref.periodic_rmnews_last_get = unixts; - REMMINA_DEBUG ("periodic_rmnews_last_get set to %ld", remmina_pref.periodic_rmnews_last_get); - REMMINA_DEBUG ("Saving preferences"); - remmina_pref_save(); - return; - } - sb = soup_message_body_flatten(msg->response_body); - if (output_file) { - fwrite(sb->data, 1, sb->length, output_file); - - if (output_file_path) { - fclose(output_file); - filesha_after = remmina_sha1_file(output_file_path); - } - REMMINA_DEBUG("SHA1 after download is %s", filesha_after); - if (g_strcmp0(filesha, filesha_after) != 0) { - REMMINA_DEBUG("SHA1 differs, we show the news and reset the counter"); - remmina_pref.periodic_rmnews_last_get = 0; - REMMINA_DEBUG ("periodic_rmnews_last_get set to %ld", remmina_pref.periodic_rmnews_last_get); - REMMINA_DEBUG ("Saving preferences"); - GtkWindow *parent = remmina_main_get_window(); - if (!kioskmode && kioskmode == FALSE) - rmnews_show_news(parent); - } else { - remmina_pref.periodic_rmnews_last_get = unixts; - } - /* Increase counter with number of successful GETs */ - remmina_pref.periodic_rmnews_get_count = remmina_pref.periodic_rmnews_get_count + 1; - remmina_pref_save(); - g_free(filesha); filesha = NULL; - } - } - - g_object_unref(msg); -} -#endif - -/** - * Try to get a unique system+user ID to identify this remmina user - * and avoid some duplicated task, especially on news management - * @return a string - * @warning The returned string must be freed with g_free. - */ -gchar *rmnews_get_uid() -{ - TRACE_CALL(__func__); - GChecksum *chs; - const gchar *uname, *hname; - const gchar *uid_suffix; - gchar *uid_prefix; - gchar *uid; - - /* This code is very similar to remmina_stats_get_uid() */ - - if (remmina_pref.periodic_rmnews_uuid_prefix == NULL || remmina_pref.periodic_rmnews_uuid_prefix[0] == 0) { - /* Generate a new UUID_PREFIX for news on this installation */ - uid_prefix = remmina_gen_random_uuid(); - if (remmina_pref.periodic_rmnews_uuid_prefix) - g_free(remmina_pref.periodic_rmnews_uuid_prefix); - remmina_pref.periodic_rmnews_uuid_prefix = uid_prefix; - remmina_pref_save(); - } - - uname = g_get_user_name(); - hname = g_get_host_name(); - chs = g_checksum_new(G_CHECKSUM_SHA256); - g_checksum_update(chs, (const guchar *)uname, strlen(uname)); - g_checksum_update(chs, (const guchar *)hname, strlen(hname)); - uid_suffix = g_checksum_get_string(chs); - - uid = g_strdup_printf("02-%s-%.10s", remmina_pref.periodic_rmnews_uuid_prefix, uid_suffix); - g_checksum_free(chs); - - return uid; -} - -void rmnews_get_url(const char *url) -{ - TRACE_CALL(__func__); - - SoupMessage *msg; - - msg = soup_message_new("GET", url); - soup_message_set_flags(msg, SOUP_MESSAGE_NO_REDIRECT); - - REMMINA_DEBUG("Fetching %s", url); - -#if SOUP_CHECK_VERSION (2, 99, 2) - // Use soup_session_send_async or soup_session_send_and_read_async - soup_session_send_async ( session, msg, G_PRIORITY_DEFAULT, - NULL, // cancellable - rmnews_get_url_cb, // callback - NULL); // user_data -#else - g_object_ref(msg); - soup_session_queue_message(session, msg, rmnews_get_url_cb, NULL); -#endif -} - -void rmnews_get_news() -{ - TRACE_CALL(__func__); - - SoupLogger *logger = NULL; - int fd; - gchar *uid; - gchar mage[20], gcount[20]; - struct stat sb; - - gchar *cachedir = g_build_path("/", g_get_user_cache_dir(), REMMINA_APP_ID, NULL); - gint d = g_mkdir_with_parents(cachedir, 0750); - if (d < 0) - output_file_path = RMNEWS_OUTPUT; - else - output_file_path = g_build_path("/", cachedir, "latest_news.md", NULL); - - REMMINA_DEBUG("Output file set to %s", output_file_path); - - if (remmina_pref.periodic_rmnews_last_get == 0 && - remmina_pref.periodic_rmnews_get_count == 0) { - g_file_set_contents(output_file_path, "", 0, NULL); - /* Just a symolic date */ - remmina_pref.periodic_rmnews_last_get = 191469343000; - REMMINA_DEBUG ("periodic_rmnews_last_get set to %ld", remmina_pref.periodic_rmnews_last_get); - REMMINA_DEBUG ("Preferences NOT saved"); - } - - fd = g_open(output_file_path, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); - REMMINA_DEBUG("Returned %d while creating %s", fd, output_file_path); - /* If we cannot create the remmina_news file, we avoid connections */ - if (fd < 0) { - REMMINA_DEBUG("Cannot store the remmina news file"); - return; - } - g_close(fd, NULL); - - REMMINA_DEBUG("Output file %s created successfully", output_file_path); - - if (output_file_path) { - } else { - REMMINA_DEBUG("Output file set to %s", output_file_path); - } - - REMMINA_DEBUG("Gathering news"); - /* Build the session with all of the features we need */ - session = soup_session_new_with_options ("user-agent", "get ", - "accept-language-auto", TRUE, - "timeout", 15, - NULL); - -#if SOUP_CHECK_VERSION (2, 99, 2) - soup_session_add_feature_by_type (session, SOUP_TYPE_COOKIE_JAR); - logger = soup_logger_new(SOUP_LOGGER_LOG_NONE); -#else - session = g_object_new(SOUP_TYPE_SESSION, - SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_DECODER, - SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_COOKIE_JAR, - SOUP_SESSION_USER_AGENT, "get ", - SOUP_SESSION_ACCEPT_LANGUAGE_AUTO, TRUE, - NULL); - logger = soup_logger_new(SOUP_LOGGER_LOG_NONE, -1); -#endif - /* TODO: Catch log level and set SOUP_LOGGER_LOG_MINIMAL or more */ - soup_session_add_feature(session, SOUP_SESSION_FEATURE(logger)); - g_object_unref(logger); - - gchar *lang = remmina_utils_get_lang(); - REMMINA_DEBUG("Language %s", lang); - - uid = rmnews_get_uid(); - - if (stat("/etc/machine-id", &sb) == 0) - sprintf(mage, "%ld", (long)(time(NULL) - sb.st_mtim.tv_sec)); - else - strcpy(mage, "0"); - - sprintf(gcount, "%ld", remmina_pref.periodic_rmnews_get_count); - - rmnews_get_url(g_strconcat(REMMINA_URL, - "news/remmina_news.php?lang=", - lang, - "&ver=" - VERSION, - "&uid=", - uid, - "&sa=0", - "&mage=", - mage, - "&gcount=", - gcount, - NULL)); - - g_free(uid); - g_object_unref(session); -} - -static gboolean rmnews_periodic_check(gpointer user_data) -{ - TRACE_CALL(__func__); - GDateTime *gdt; - gint64 unixts; - glong next = 0; - - gdt = g_date_time_new_now_utc(); - unixts = g_date_time_to_unix(gdt); - g_date_time_unref(gdt); - - /* if remmina_pref is not writable ... */ - if (remmina_pref_is_rw() == FALSE && remmina_pref.periodic_rmnews_last_get == 0) { - /* We randomly set periodic_rmnews_last_get to a day between today - * and 7 days ago */ - gint randidx = randombytes_uniform(8); - REMMINA_DEBUG("Setting a random periodic_rmnews_last_get to %d - %d", unixts, eweekdays[randidx]); - remmina_pref.periodic_rmnews_last_get = unixts - eweekdays[randidx]; - } - //REMMINA_DEBUG("periodic_rmnews_last_get is %ld", remmina_pref.periodic_rmnews_last_get); - - if (remmina_pref.periodic_news_permitted == 0 && remmina_pref.periodic_rmnews_get_count < 1) { - remmina_pref.periodic_rmnews_last_get = - (remmina_pref.periodic_rmnews_last_get > 1514764800 ? remmina_pref.periodic_rmnews_last_get : 0); - remmina_pref_save(); - } - next = remmina_pref.periodic_rmnews_last_get + RMNEWS_INTERVAL_SEC; - if (unixts > next || (unixts < remmina_pref.periodic_rmnews_last_get && unixts > 1514764800)) { - //REMMINA_DEBUG("remmina_pref.periodic_news_permitted is %d", remmina_pref.periodic_news_permitted); - if (remmina_pref.periodic_news_permitted == 1) { - rmnews_get_news(); - } else if (remmina_pref.periodic_rmnews_get_count == 0) { - rmnews_show_news(remmina_main_get_window()); - remmina_pref.periodic_rmnews_get_count = 1; - remmina_pref_save(); - } - } - return G_SOURCE_CONTINUE; -} - -void rmnews_schedule() -{ - TRACE_CALL(__func__); - remmina_scheduler_setup(rmnews_periodic_check, - NULL, - RMNEWS_CHECK_1ST_MS, - RMNEWS_CHECK_INTERVAL_MS); -} diff --git a/src/rmnews.h b/src/rmnews.h deleted file mode 100644 index 734ffe1d0..000000000 --- a/src/rmnews.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Remmina - The GTK+ Remote Desktop Client - * Copyright (C) 2016-2022 Antenore Gatta, Giovanni Panozzo - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * In addition, as a special exception, the copyright holders give - * permission to link the code of portions of this program with the - * OpenSSL library under certain conditions as described in each - * individual source file, and distribute linked combinations - * including the two. - * You must obey the GNU General Public License in all respects - * for all of the code used other than OpenSSL. * If you modify - * file(s) with this exception, you may extend this exception to your - * version of the file(s), but you are not obligated to do so. * If you - * do not wish to do so, delete this exception statement from your - * version. * If you delete this exception statement from all source - * files in the program, then also delete it here. - * - */ - -typedef struct _RemminaNewsDialog { - GtkBuilder * builder; - GtkDialog * dialog; - - GtkTextView * rmnews_text_view; - GtkLabel * rmnews_label; - GtkButton * rmnews_button_close; - GtkLabel * rmnews_defaultcl_label; - GtkButton * rmnews_defaultcl_button; - GtkSwitch * rmnews_news_switch; - - gint retval; -} RemminaNewsDialog; - -#pragma once - -#include <gtk/gtk.h> - -G_BEGIN_DECLS -extern gboolean disablenews; -void rmnews_schedule(); -void rmnews_show_news(); -void rmnews_get_url(const char *url); -G_END_DECLS |