Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDA support: Make MATE's screensaver aware of being run inside a remo… #159

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ X11_REQUIRED_VERSION=1.0
LIBMATE_MENU_REQUIRED_VERSION=1.21.0
MATE_DESKTOP_REQUIRED_VERSION=1.17.0
LIBMATEKBDUI_REQUIRED_VERSION=1.17.0
RDA_REQUIRED_VERSION=0.0.3

AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(crypt.h sys/select.h)
Expand Down Expand Up @@ -428,6 +429,15 @@ elif test "$with_xf86gamma" != no; then
exit 1
fi

dnl ---------------------------------------------------------------------------
dnl - Check if Remote Desktop Awareness support is available
dnl ---------------------------------------------------------------------------

PKG_CHECK_MODULES(RDA, rda >= $RDA_REQUIRED_VERSION, have_rda=yes, have_rda=no)
if test "x$have_rda" = "xyes"; then
AC_DEFINE(HAVE_RDA, 1, [Have the Remote Desktop Awareness library])
fi

dnl ---------------------------------------------------------------------------
dnl - The --enable-locking option
dnl ---------------------------------------------------------------------------
Expand Down Expand Up @@ -1156,6 +1166,7 @@ echo "
Have enhanced shadow: ${have_shadow_enhanced}
Have HPUX shadow: ${have_shadow_hpux}
Have password helper: ${have_passwd_helper}
Have RD awareness: ${have_rda}
Authentication scheme: ${AUTH_SCHEME}"

if test "x$need_setuid" = "xyes" -a "x$have_pam" != "xyes" ; then
Expand Down
22 changes: 19 additions & 3 deletions data/lock-dialog-default.ui
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,22 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="auth-suspend-button">
<property name="label" translatable="yes">_Disconnect</property>
<property name="visible">False</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="auth-logout-button">
<property name="label" translatable="yes">_Log Out</property>
Expand All @@ -262,7 +278,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
<child>
Expand All @@ -278,7 +294,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child>
Expand All @@ -293,7 +309,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
</object>
Expand Down
4 changes: 4 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ AM_CPPFLAGS = \
$(LIBNOTIFY_CFLAGS) \
$(SYSTEMD_CFLAGS) \
$(LIBELOGIND_CFLAGS) \
$(RDA_CFLAGS) \
$(NULL)

bin_PROGRAMS = \
Expand Down Expand Up @@ -131,6 +132,7 @@ test_window_SOURCES = \
test_window_LDADD = \
$(MATE_SCREENSAVER_LIBS) \
$(SAVER_LIBS) \
$(RDA_LIBS) \
$(NULL)

mate_screensaver_dialog_SOURCES = \
Expand Down Expand Up @@ -159,6 +161,7 @@ mate_screensaver_dialog_LDADD = \
$(AUTH_LIBS) \
$(LIBMATEKBDUI_LIBS) \
$(LIBNOTIFY_LIBS) \
$(RDA_LIBS) \
$(NULL)

BUILT_SOURCES = \
Expand Down Expand Up @@ -219,6 +222,7 @@ mate_screensaver_LDADD = \
$(SAVER_LIBS) \
$(SYSTEMD_LIBS) \
$(LIBELOGIND_LIBS) \
$(RDA_LIBS) \
$(NULL)

mate_screensaver_LDFLAGS = -export-dynamic
Expand Down
123 changes: 123 additions & 0 deletions src/gs-lock-plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include <gtk/gtkx.h>
#include <gio/gio.h>

#ifdef HAVE_RDA
#include <rda/rda.h>
#endif /* HAVE_RDA */

#define MATE_DESKTOP_USE_UNSTABLE_API
#include <libmate-desktop/mate-desktop-utils.h>

Expand Down Expand Up @@ -99,6 +103,7 @@ struct GSLockPlugPrivate
GtkWidget *auth_switch_button;
GtkWidget *auth_cancel_button;
GtkWidget *auth_logout_button;
GtkWidget *auth_suspend_button;
GtkWidget *auth_note_button;
GtkWidget *note_tab;
GtkWidget *note_tab_label;
Expand All @@ -110,6 +115,9 @@ struct GSLockPlugPrivate

gboolean caps_lock_on;
gboolean switch_enabled;
#ifdef HAVE_RDA
gboolean suspend_enabled;
#endif /* HAVE_RDA */
gboolean leave_note_enabled;
gboolean logout_enabled;
char *logout_command;
Expand Down Expand Up @@ -146,6 +154,9 @@ enum
PROP_LOGOUT_ENABLED,
PROP_LOGOUT_COMMAND,
PROP_SWITCH_ENABLED,
#ifdef HAVE_RDA
PROP_SUSPEND_ENABLED,
#endif /* HAVE_RDA */
PROP_STATUS_MESSAGE
};

Expand Down Expand Up @@ -1094,6 +1105,37 @@ gs_lock_plug_set_logout_enabled (GSLockPlug *plug,
}
}

#ifdef HAVE_RDA
static void
gs_lock_plug_set_suspend_enabled (GSLockPlug *plug,
gboolean suspend_enabled)
{
g_return_if_fail (GS_LOCK_PLUG (plug));

if (plug->priv->suspend_enabled == suspend_enabled)
{
return;
}

plug->priv->suspend_enabled = suspend_enabled;
g_object_notify (G_OBJECT (plug), "suspend-enabled");

if (plug->priv->auth_suspend_button == NULL)
{
return;
}

if (suspend_enabled)
{
gtk_widget_show (plug->priv->auth_suspend_button);
}
else
{
gtk_widget_hide (plug->priv->auth_suspend_button);
}
}
#endif /* HAVE_RDA */

static void
gs_lock_plug_set_logout_command (GSLockPlug *plug,
const char *command)
Expand Down Expand Up @@ -1157,6 +1199,11 @@ gs_lock_plug_get_property (GObject *object,
case PROP_SWITCH_ENABLED:
g_value_set_boolean (value, self->priv->switch_enabled);
break;
#ifdef HAVE_RDA
case PROP_SUSPEND_ENABLED:
g_value_set_boolean (value, self->priv->suspend_enabled);
break;
#endif /* HAVE_RDA */
case PROP_STATUS_MESSAGE:
g_value_set_string (value, self->priv->status_message);
break;
Expand Down Expand Up @@ -1187,6 +1234,12 @@ gs_lock_plug_set_switch_enabled (GSLockPlug *plug,

if (switch_enabled)
{
#ifdef HAVE_RDA
if (rda_session_is_remote()) {
gs_debug ("No switch user capability if session is remote");
gtk_widget_hide (plug->priv->auth_switch_button);
} else
#endif /* HAVE_RDA */
if (process_is_running ("mdm"))
{
/* MDM */
Expand Down Expand Up @@ -1238,6 +1291,11 @@ gs_lock_plug_set_property (GObject *object,
case PROP_SWITCH_ENABLED:
gs_lock_plug_set_switch_enabled (self, g_value_get_boolean (value));
break;
#ifdef HAVE_RDA
case PROP_SUSPEND_ENABLED:
gs_lock_plug_set_suspend_enabled (self, g_value_get_boolean (value));
break;
#endif /* HAVE_RDA */
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
Expand Down Expand Up @@ -1325,6 +1383,15 @@ gs_lock_plug_class_init (GSLockPlugClass *klass)
NULL,
FALSE,
G_PARAM_READWRITE));
#ifdef HAVE_RDA
g_object_class_install_property (object_class,
PROP_SUSPEND_ENABLED,
g_param_spec_boolean ("suspend-enabled",
NULL,
NULL,
FALSE,
G_PARAM_READWRITE));
#endif /* HAVE_RDA */

binding_set = gtk_binding_set_by_class (klass);

Expand Down Expand Up @@ -1452,6 +1519,25 @@ logout_button_clicked (GtkButton *button,
}
}

#ifdef HAVE_RDA
static void
suspend_button_clicked (GtkButton *button,
GSLockPlug *plug)
{
remove_response_idle (plug);

gs_lock_plug_set_sensitive (plug, FALSE);

plug->priv->response_idle_id = g_timeout_add (2000,
(GSourceFunc)response_cancel_idle_cb,
plug);

gs_lock_plug_set_busy (plug);

rda_session_suspend();
}
#endif

void
gs_lock_plug_set_busy (GSLockPlug *plug)
{
Expand Down Expand Up @@ -1666,6 +1752,12 @@ create_page_one_buttons (GSLockPlug *plug)
gtk_widget_set_focus_on_click (GTK_WIDGET (plug->priv->auth_logout_button), FALSE);
gtk_widget_set_no_show_all (plug->priv->auth_logout_button, TRUE);

plug->priv->auth_suspend_button = gs_lock_plug_add_button (GS_LOCK_PLUG (plug),
plug->priv->auth_action_area,
_("Disconnect"));
gtk_widget_set_focus_on_click (GTK_WIDGET (plug->priv->auth_suspend_button), FALSE);
gtk_widget_set_no_show_all (plug->priv->auth_suspend_button, TRUE);

plug->priv->auth_cancel_button = gs_lock_plug_add_button (GS_LOCK_PLUG (plug),
plug->priv->auth_action_area,
"gtk-cancel");
Expand Down Expand Up @@ -2049,6 +2141,7 @@ load_theme (GSLockPlug *plug)
plug->priv->auth_cancel_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-cancel-button"));
plug->priv->auth_logout_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-logout-button"));
plug->priv->auth_switch_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-switch-button"));
plug->priv->auth_suspend_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-suspend-button"));
plug->priv->auth_note_button = GTK_WIDGET (gtk_builder_get_object(builder, "auth-note-button"));
plug->priv->note_tab = GTK_WIDGET (gtk_builder_get_object(builder, "note-tab"));
plug->priv->note_tab_label = GTK_WIDGET (gtk_builder_get_object(builder, "note-tab-label"));
Expand All @@ -2066,6 +2159,10 @@ load_theme (GSLockPlug *plug)
{
gtk_widget_set_no_show_all (plug->priv->auth_switch_button, TRUE);
}
if (plug->priv->auth_suspend_button != NULL)
{
gtk_widget_set_no_show_all (plug->priv->auth_suspend_button, TRUE);
}
if (plug->priv->auth_note_button != NULL)
{
gtk_widget_set_no_show_all (plug->priv->auth_note_button, TRUE);
Expand Down Expand Up @@ -2224,6 +2321,24 @@ gs_lock_plug_init (GSLockPlug *plug)
}
}

#ifdef HAVE_RDA
if (! plug->priv->suspend_enabled)
{
if (plug->priv->auth_suspend_button != NULL)
{
gtk_widget_hide (plug->priv->auth_suspend_button);
}
}
if (plug->priv->auth_suspend_button != NULL)
{
gchar *btn_label;
btn_label = g_strdup_printf (_("_Disconnect %s"), rda_get_remote_technology_name());
gs_debug ("Renaming remote suspension button to %s", btn_label);
gtk_button_set_label (GTK_BUTTON (plug->priv->auth_suspend_button), btn_label);
g_free (btn_label);
}
#endif /* HAVE_RDA */

plug->priv->timeout = DIALOG_TIMEOUT_MSEC;

g_signal_connect (plug, "key_press_event",
Expand Down Expand Up @@ -2260,6 +2375,14 @@ gs_lock_plug_init (GSLockPlug *plug)
G_CALLBACK (switch_user_button_clicked), plug);
}

#ifdef HAVE_RDA
if (plug->priv->auth_suspend_button != NULL)
{
g_signal_connect (plug->priv->auth_suspend_button, "clicked",
G_CALLBACK (suspend_button_clicked), plug);
}
#endif /* HAVE_RDA */

if (plug->priv->auth_note_button != NULL)
{
g_signal_connect (plug->priv->auth_note_button, "clicked",
Expand Down
11 changes: 11 additions & 0 deletions src/gs-window-x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include <gtk/gtk.h>
#include <gtk/gtkx.h>

#ifdef HAVE_RDA
#include <rda/rda.h>
#endif

#include "gs-window.h"
#include "gs-marshal.h"
#include "subprocs.h"
Expand Down Expand Up @@ -1725,6 +1729,13 @@ popup_dialog (GSWindow *window)
command = g_string_append (command, " --enable-switch");
}

#ifdef HAVE_RDA
if (rda_session_is_remote() && rda_session_can_be_suspended())
{
command = g_string_append (command, " --enable-suspend");
}
#endif /* HAVE_RDA */

if (gs_debug_enabled ())
{
command = g_string_append (command, " --verbose");
Expand Down
Loading