File: app.h

package info (click to toggle)
slim 1.4.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,792 kB
  • sloc: cpp: 4,383; sh: 200; makefile: 23
file content (109 lines) | stat: -rw-r--r-- 2,930 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* SLiM - Simple Login Manager
 *  Copyright (C) 1997, 1998 Per Liden
 *  Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
 *  Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
 *  Copyright (C) 2022-23 Rob Pearce <slim@flitspace.org.uk>
 *
 *  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.
 */

#ifndef _APP_H_
#define _APP_H_

#include <X11/Xlib.h>

#ifdef USE_PAM
#include "PAM.h"
#endif
#ifdef USE_CONSOLEKIT
#include "Ck.h"
#endif

// Forward declarations
class Panel;
class Cfg;


class App
{
public:
	App(int argc, char **argv);
	~App();
	void Run();
	int GetServerPID();
	void RestartServer();
	void StopServer();

	/* Lock functions */
	void GetLock();
	void RemoveLock();

	bool isServerStarted();

private:
	void Login();
	void Reboot();
	void Halt();
	void Suspend();
	void Console();
	void Exit();
	void KillAllClients(Bool top);
	void ReadConfig();
	void OpenLog();
	void CloseLog();
	void CreateServerAuth();
	char *StrConcat(const char *str1, const char *str2);
	void UpdatePid();

	bool AuthenticateUser(bool focuspass);

	static void replaceVariables(std::string &input,
								 const std::string &var,
								 const std::string &value);

	/* Server functions */
	int StartServer();
	int ServerTimeout(int timeout, char *string);
	int WaitForServer();

	/* Private data */
	Window Root;	///< The root window of the default screen, on which to draw
	Display *Dpy;	///< Connection to the X-server
	int Scr;		///< Which "screen" to use (which will be the default one)
	Panel *LoginPanel;	///< The panel we display and interact through
	int ServerPID;	///< Process ID of the X-server we launched
	const char *DisplayName;	///< The display to request, usually ":0.0"
	bool serverStarted;	///< Whether we (think we) have started an X server

#ifdef USE_PAM
	PAM::Authenticator pam;	///< Interface to the PAM authentication library
#endif
#ifdef USE_CONSOLEKIT
	Ck::Session ck;		///< Interface to ConsoleKit, if used
#endif

	/* Options */
	Cfg *cfg;		///< Collection of options from the configuration file

	void blankScreen();

	bool firstlogin;	///< Whether to exhibit first login behaviour, or repeat
	bool daemonmode;	///< Are we running as a daemon?
	bool force_nodaemon;	///< Are we forced NOT to be a daemon?
	/* For testing themes */
	char *testtheme;	///< Name of the theme to test, from command line
	bool testing;		///< Whether we're running in theme testing mode
	short tww, twh;		///< The user's requested test window size

#ifdef USE_CONSOLEKIT
	bool consolekit_support_enabled;	///< Whether to use ConsoleKit (not compatible with systemd)
#endif

	std::string themeName;	///< Name of the theme in use
	std::string mcookie;	///< Randomly generated X auth cookie
};

#endif /* _APP_H_ */