Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/Remmina/Remmina.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntenore Gatta (tmow) <antenore@simbiosi.org>2022-01-10 09:19:26 +0300
committerAntenore Gatta (tmow) <antenore@simbiosi.org>2022-01-10 09:19:26 +0300
commitf69915048ea76fa48eec44af8db3e416727a1c9d (patch)
tree5dd32798869fa1ebfaa79942f96407322f06f1fd
parent4d6dab084a89b51ba2aa25efc415ad0a716bc072 (diff)
Adding new files
-rw-r--r--data/ui/remmina_passwd.glade168
-rw-r--r--data/ui/remmina_preferences.glade6
-rw-r--r--src/remmina_passwd.c157
-rw-r--r--src/remmina_passwd.h58
4 files changed, 386 insertions, 3 deletions
diff --git a/data/ui/remmina_passwd.glade b/data/ui/remmina_passwd.glade
new file mode 100644
index 000000000..a98df1771
--- /dev/null
+++ b/data/ui/remmina_passwd.glade
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface>
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkDialog" id="RemminaPasswdDialog">
+ <property name="can-focus">False</property>
+ <property name="type-hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <property name="can-focus">False</property>
+ <property name="layout-style">end</property>
+ <child>
+ <object class="GtkButton" id="button_cancel">
+ <property name="label" translatable="yes">Cancel</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="always-show-image">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_submit">
+ <property name="label" translatable="yes">OK</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHeaderBar">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">Set Primary Password</property>
+ <property name="show-close-button">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <!-- n-columns=2 n-rows=2 -->
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="margin-start">18</property>
+ <property name="margin-end">6</property>
+ <property name="margin-top">18</property>
+ <property name="margin-bottom">9</property>
+ <property name="label" translatable="yes">Password</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="margin-start">18</property>
+ <property name="margin-end">6</property>
+ <property name="margin-top">9</property>
+ <property name="margin-bottom">18</property>
+ <property name="label" translatable="yes">Verify password</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry_password">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="valign">start</property>
+ <property name="margin-start">6</property>
+ <property name="margin-end">18</property>
+ <property name="margin-top">18</property>
+ <property name="margin-bottom">9</property>
+ <property name="visibility">False</property>
+ <property name="invisible-char">•</property>
+ <property name="width-chars">24</property>
+ <property name="input-purpose">password</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry_verify">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="valign">start</property>
+ <property name="margin-start">6</property>
+ <property name="margin-end">18</property>
+ <property name="margin-top">9</property>
+ <property name="margin-bottom">18</property>
+ <property name="visibility">False</property>
+ <property name="invisible-char">•</property>
+ <property name="width-chars">24</property>
+ <property name="shadow-type">none</property>
+ <property name="input-purpose">password</property>
+ <signal name="changed" handler="remmina_passwd_repwd_on_changed" swapped="no"/>
+ <style>
+ <class name="entry_verify"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/data/ui/remmina_preferences.glade b/data/ui/remmina_preferences.glade
index 1418c189d..755acc51b 100644
--- a/data/ui/remmina_preferences.glade
+++ b/data/ui/remmina_preferences.glade
@@ -1612,7 +1612,7 @@ It changes the background colour of connection names in the Remmina connection t
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
- <property name="shadow-type">none</property>
+ <property name="shadow-type">out</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
@@ -1831,7 +1831,7 @@ It changes the background colour of connection names in the Remmina connection t
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
- <property name="shadow-type">none</property>
+ <property name="shadow-type">out</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
@@ -1896,7 +1896,7 @@ It changes the background colour of connection names in the Remmina connection t
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
- <property name="shadow-type">none</property>
+ <property name="shadow-type">out</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
diff --git a/src/remmina_passwd.c b/src/remmina_passwd.c
new file mode 100644
index 000000000..f2a34f9df
--- /dev/null
+++ b/src/remmina_passwd.c
@@ -0,0 +1,157 @@
+/*
+ * 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 <stdlib.h>
+
+#include <glib/gi18n.h>
+
+#include "config.h"
+#include "remmina_public.h"
+#include "remmina_log.h"
+#include "remmina_sodium.h"
+#include "remmina_passwd.h"
+#include "remmina/remmina_trace_calls.h"
+
+static RemminaPasswdDialog *remmina_passwd_dialog;
+#define GET_OBJ(object_name) gtk_builder_get_object(remmina_passwd_dialog->builder, object_name)
+
+void remmina_passwd_repwd_on_changed(GtkEditable *editable, RemminaPasswdDialog *dialog)
+{
+ TRACE_CALL(__func__);
+ GtkCssProvider *provider;
+ const gchar *color;
+ const gchar *password;
+ const gchar *verify;
+ gboolean sensitive = FALSE;
+
+ provider = gtk_css_provider_new();
+
+ password = gtk_entry_get_text(remmina_passwd_dialog->entry_password);
+ verify = gtk_entry_get_text(remmina_passwd_dialog->entry_verify);
+ if (g_strcmp0(password, verify) == 0) {
+ color = g_strdup("green");
+ sensitive = TRUE;
+ } else
+ color = g_strdup("red");
+
+ gtk_widget_set_sensitive (GTK_WIDGET(remmina_passwd_dialog->button_submit), sensitive);
+
+ if (verify == NULL || verify[0] == '\0')
+ color = g_strdup("inherit");
+
+ gtk_css_provider_load_from_data(provider,
+ g_strdup_printf(
+ ".entry_verify {\n"
+ " color: %s;\n"
+ "}\n"
+ , color)
+ , -1, NULL);
+ gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
+ GTK_STYLE_PROVIDER(provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+ gtk_widget_queue_draw(GTK_WIDGET(remmina_passwd_dialog->entry_verify));
+ g_object_unref(provider);
+}
+
+static void remmina_passwd_password_activate(GtkEntry *entry, gpointer user_data)
+{
+ TRACE_CALL(__func__);
+
+ gtk_widget_grab_focus(GTK_WIDGET(remmina_passwd_dialog->entry_verify));
+
+}
+
+static void remmina_passwd_cancel_clicked(GtkButton *btn, gpointer user_data)
+{
+ TRACE_CALL(__func__);
+ gtk_widget_destroy(GTK_WIDGET(remmina_passwd_dialog->dialog));
+ remmina_passwd_dialog->dialog = NULL;
+}
+
+static void remmina_passwd_submit_clicked(GtkButton *btn, gpointer user_data)
+{
+ TRACE_CALL(__func__);
+ remmina_passwd_dialog->password = gtk_entry_get_text(
+ GTK_ENTRY(remmina_passwd_dialog->entry_verify));
+ gtk_dialog_response (remmina_passwd_dialog->dialog, GTK_RESPONSE_ACCEPT);
+}
+
+void remmina_passwd(GtkWindow *parent, gchar **unlock_password)
+{
+ TRACE_CALL(__func__);
+
+ remmina_passwd_dialog = g_new0(RemminaPasswdDialog, 1);
+
+ remmina_passwd_dialog->builder = remmina_public_gtk_builder_new_from_resource("/org/remmina/Remmina/src/../data/ui/remmina_passwd.glade");
+ remmina_passwd_dialog->dialog = GTK_DIALOG(GET_OBJ("RemminaPasswdDialog"));
+ if (parent)
+ gtk_window_set_transient_for(GTK_WINDOW(remmina_passwd_dialog->dialog), parent);
+
+ remmina_passwd_dialog->entry_password = GTK_ENTRY(GET_OBJ("entry_password"));
+ remmina_passwd_dialog->entry_verify = GTK_ENTRY(GET_OBJ("entry_verify"));
+ gtk_entry_set_activates_default(GTK_ENTRY(remmina_passwd_dialog->entry_verify), TRUE);
+ remmina_passwd_dialog->button_submit = GTK_BUTTON(GET_OBJ("button_submit"));
+ gtk_widget_set_can_default(GTK_WIDGET(remmina_passwd_dialog->button_submit), TRUE);
+ gtk_widget_grab_default(GTK_WIDGET(remmina_passwd_dialog->button_submit));
+ remmina_passwd_dialog->button_cancel = GTK_BUTTON(GET_OBJ("button_cancel"));
+
+ g_signal_connect(remmina_passwd_dialog->entry_password, "activate",
+ G_CALLBACK(remmina_passwd_password_activate), (gpointer)remmina_passwd_dialog);
+ g_signal_connect(remmina_passwd_dialog->button_submit, "clicked",
+ G_CALLBACK(remmina_passwd_submit_clicked), (gpointer)remmina_passwd_dialog);
+ g_signal_connect(remmina_passwd_dialog->button_cancel, "clicked",
+ G_CALLBACK(remmina_passwd_cancel_clicked), (gpointer)remmina_passwd_dialog);
+
+ /* Connect signals */
+ gtk_builder_connect_signals(remmina_passwd_dialog->builder, NULL);
+
+ int result = gtk_dialog_run(remmina_passwd_dialog->dialog);
+ switch (result)
+ {
+ case GTK_RESPONSE_ACCEPT:
+#if SODIUM_VERSION_INT >= 90200
+ //REMMINA_DEBUG ("Password before encryption: %s", remmina_passwd_dialog->password);
+ *unlock_password = remmina_sodium_pwhash_str(remmina_passwd_dialog->password);
+#else
+ *unlock_password = g_strdup(remmina_passwd_dialog->password);
+#endif
+ //REMMINA_DEBUG ("Password after encryption is: %s", *unlock_password);
+ remmina_passwd_dialog->password = NULL;
+ break;
+ default:
+ break;
+ }
+ gtk_widget_destroy(GTK_WIDGET(remmina_passwd_dialog->dialog));
+}
diff --git a/src/remmina_passwd.h b/src/remmina_passwd.h
new file mode 100644
index 000000000..3c214d1ac
--- /dev/null
+++ b/src/remmina_passwd.h
@@ -0,0 +1,58 @@
+/*
+ * Remmina - The GTK+ Remote Desktop Client
+ * Copyright (C) 2017-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.
+ *
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+typedef struct _RemminaPasswdDialog {
+ GtkBuilder * builder;
+ GtkDialog * dialog;
+
+ GtkEntry * entry_password;
+ GtkEntry * entry_verify;
+ GtkButton * button_submit;
+ GtkButton * button_cancel;
+
+ const gchar * password;
+
+} RemminaPasswdDialog;
+
+
+G_BEGIN_DECLS
+
+void remmina_passwd(GtkWindow *parent, gchar **password_setting);
+
+G_END_DECLS