Skip to content
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
66 changes: 22 additions & 44 deletions cinnamon-session/csm-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#include "csm-autostart-app.h"

#include "csm-util.h"
#include "mdm.h"
#include "csm-system.h"
#include "csm-session-save.h"
#include "inhibit-dialog-info.h"
Expand All @@ -67,15 +66,12 @@
* want to wait, at least for something happening more than once.
* We can get deployed on very slow media though like CDROM devices,
* often with complex stacking/compressing filesystems on top, which
* is not a recipie for speed. Particularly now that we throw up

Check failure on line 69 in cinnamon-session/csm-manager.c

View workflow job for this annotation

GitHub Actions / build / build (mint22, linuxmintd/mint22.3-amd64, Mint 22, true) / Mint 22

recipie ==> recipe
* a fail whale if required components don't show up quickly enough,
* let's make this fairly long.
*/
#define CSM_MANAGER_PHASE_TIMEOUT 30 /* seconds */

#define MDM_FLEXISERVER_COMMAND "mdmflexiserver"
#define MDM_FLEXISERVER_ARGS "--startnew Standard"

#define GDM_FLEXISERVER_COMMAND "gdmflexiserver"
#define GDM_FLEXISERVER_ARGS "--startnew Standard"

Expand Down Expand Up @@ -111,10 +107,8 @@
CSM_MANAGER_LOGOUT_LOGOUT,
CSM_MANAGER_LOGOUT_REBOOT,
CSM_MANAGER_LOGOUT_REBOOT_INTERACT,
CSM_MANAGER_LOGOUT_REBOOT_MDM,
CSM_MANAGER_LOGOUT_SHUTDOWN,
CSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT,
CSM_MANAGER_LOGOUT_SHUTDOWN_MDM
CSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT
} CsmManagerLogoutType;

struct CsmManagerPrivate
Expand Down Expand Up @@ -473,14 +467,19 @@
static void start_phase (CsmManager *manager);

static void
quit_request_failed (CsmSystem *system,
GError *error,
gpointer user_data)
on_shutdown_prepared (CsmSystem *system,
gboolean success,
gpointer user_data)
{
g_warning ("Using an MDM logout action to shutdown/reboot the system.");
MdmLogoutAction fallback_action = GPOINTER_TO_INT (user_data);
mdm_set_logout_action (fallback_action);
csm_quit ();
g_signal_handlers_disconnect_by_func (system, on_shutdown_prepared, user_data);
Comment on lines +470 to +474

if (success) {
csm_system_complete_shutdown (system);
csm_quit ();
} else {
g_warning ("Shutdown/restart was not confirmed by logind; staying in session.");
csm_system_complete_shutdown (system);
}
}

static void
Expand All @@ -498,31 +497,21 @@
case CSM_MANAGER_LOGOUT_REBOOT:
case CSM_MANAGER_LOGOUT_REBOOT_INTERACT:
g_warning ("Requesting system restart...");
mdm_set_logout_action (MDM_LOGOUT_ACTION_NONE);
g_signal_connect (manager->priv->system,
"request-failed",
G_CALLBACK (quit_request_failed),
GINT_TO_POINTER (MDM_LOGOUT_ACTION_REBOOT));
"shutdown-prepared",
G_CALLBACK (on_shutdown_prepared),
manager);
csm_system_attempt_restart (manager->priv->system);
break;
case CSM_MANAGER_LOGOUT_REBOOT_MDM:
mdm_set_logout_action (MDM_LOGOUT_ACTION_REBOOT);
csm_quit ();
break;
case CSM_MANAGER_LOGOUT_SHUTDOWN:
case CSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT:
case CSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT:
g_warning ("Requesting system shutdown...");
mdm_set_logout_action (MDM_LOGOUT_ACTION_NONE);
g_signal_connect (manager->priv->system,
"request-failed",
G_CALLBACK (quit_request_failed),
GINT_TO_POINTER (MDM_LOGOUT_ACTION_SHUTDOWN));
"shutdown-prepared",
G_CALLBACK (on_shutdown_prepared),
manager);
csm_system_attempt_stop (manager->priv->system);
break;
case CSM_MANAGER_LOGOUT_SHUTDOWN_MDM:
mdm_set_logout_action (MDM_LOGOUT_ACTION_SHUTDOWN);
csm_quit ();
break;
default:
g_assert_not_reached ();
break;
Expand Down Expand Up @@ -1121,7 +1110,6 @@
manager->priv->logout_mode = CSM_MANAGER_LOGOUT_MODE_NORMAL;

manager->priv->logout_type = CSM_MANAGER_LOGOUT_NONE;
mdm_set_logout_action (MDM_LOGOUT_ACTION_NONE);

manager->priv->dialog_action = CSM_LOGOUT_ACTION_UNDEFINED;

Expand Down Expand Up @@ -1186,7 +1174,7 @@
NULL,
&error)) {
if (error) {
g_debug ("CsmManager: Unable to start MDM greeter: %s", error->message);
g_debug ("CsmManager: Unable to start greeter: %s", error->message);
g_error_free (error);
}
}
Expand All @@ -1205,15 +1193,7 @@
return;
}

if (process_is_running ("mdm")) {
const gchar *command[] = {
MDM_FLEXISERVER_COMMAND,
MDM_FLEXISERVER_ARGS,
NULL
};

flexiserver_launch (command);
} else if (process_is_running("gdm") || process_is_running("gdm3")) {
if (process_is_running("gdm") || process_is_running("gdm3")) {
const gchar *command[] = {
GDM_FLEXISERVER_COMMAND,
GDM_FLEXISERVER_ARGS,
Expand Down Expand Up @@ -1349,12 +1329,10 @@
break;
case CSM_MANAGER_LOGOUT_REBOOT:
case CSM_MANAGER_LOGOUT_REBOOT_INTERACT:
case CSM_MANAGER_LOGOUT_REBOOT_MDM:
action = CSM_LOGOUT_ACTION_REBOOT;
break;
case CSM_MANAGER_LOGOUT_SHUTDOWN:
case CSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT:
case CSM_MANAGER_LOGOUT_SHUTDOWN_MDM:
action = CSM_LOGOUT_ACTION_SHUTDOWN;
break;
default:
Expand Down
20 changes: 20 additions & 0 deletions cinnamon-session/csm-system.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

enum {
REQUEST_FAILED = 0,
SHUTDOWN_PREPARED,
LAST_SIGNAL
};

Expand All @@ -50,6 +51,17 @@ csm_system_default_init (CsmSystemInterface *iface)
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE,
1, G_TYPE_POINTER);

signals [SHUTDOWN_PREPARED] =
g_signal_new ("shutdown-prepared",
CSM_TYPE_SYSTEM,
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE,
1, G_TYPE_BOOLEAN);
}

GQuark
Expand Down Expand Up @@ -112,6 +124,14 @@ csm_system_attempt_restart (CsmSystem *system)
CSM_SYSTEM_GET_IFACE (system)->attempt_restart (system);
}

void
csm_system_complete_shutdown (CsmSystem *system)
{
if (CSM_SYSTEM_GET_IFACE (system)->complete_shutdown != NULL) {
CSM_SYSTEM_GET_IFACE (system)->complete_shutdown (system);
}
}

void
csm_system_hybrid_sleep (CsmSystem *system)
{
Expand Down
3 changes: 3 additions & 0 deletions cinnamon-session/csm-system.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct _CsmSystemInterface
gboolean (* can_hibernate) (CsmSystem *system);
void (* attempt_stop) (CsmSystem *system);
void (* attempt_restart) (CsmSystem *system);
void (* complete_shutdown) (CsmSystem *system);
void (* hybrid_sleep) (CsmSystem *system);
void (* suspend) (CsmSystem *system,
gboolean suspend_then_hibernate);
Expand Down Expand Up @@ -100,6 +101,8 @@ void csm_system_attempt_stop (CsmSystem *system);

void csm_system_attempt_restart (CsmSystem *system);

void csm_system_complete_shutdown (CsmSystem *system);

void csm_system_hybrid_sleep (CsmSystem *system);

void csm_system_suspend (CsmSystem *system,
Expand Down
Loading
Loading