1 /* SLiM - Simple Login Manager
2    Copyright (C) 1997, 1998 Per Liden
3    Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
4    Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10 */
11 
12 #ifndef _APP_H_
13 #define _APP_H_
14 
15 #include <X11/Xlib.h>
16 #include <X11/Xatom.h>
17 #include <signal.h>
18 #include <unistd.h>
19 #include <sys/wait.h>
20 #include <errno.h>
21 #include <setjmp.h>
22 #include <stdlib.h>
23 #include <iostream>
24 #include "panel.h"
25 #include "cfg.h"
26 #include "image.h"
27 
28 #ifdef USE_PAM
29 #include "PAM.h"
30 #endif
31 #ifdef USE_CONSOLEKIT
32 #include "Ck.h"
33 #endif
34 
35 class App {
36 public:
37 	App(int argc, char **argv);
38 	~App();
39 	void Run();
40 	int GetServerPID();
41 	void RestartServer();
42 	void StopServer();
43 
44 	/* Lock functions */
45 	void GetLock();
46 	void RemoveLock();
47 
48 	bool isServerStarted();
49 
50 private:
51 	void Login();
52 	void Reboot();
53 	void Halt();
54 	void Suspend();
55 	void Console();
56 	void Exit();
57 	void KillAllClients(Bool top);
58 	void ReadConfig();
59 	void OpenLog();
60 	void CloseLog();
61 	void HideCursor();
62 	void CreateServerAuth();
63 	char *StrConcat(const char *str1, const char *str2);
64 	void UpdatePid();
65 
66 	bool AuthenticateUser(bool focuspass);
67 
68 	static std::string findValidRandomTheme(const std::string &set);
69 	static void replaceVariables(std::string &input,
70 								 const std::string &var,
71 								 const std::string &value);
72 
73 	/* Server functions */
74 	int StartServer();
75 	int ServerTimeout(int timeout, char *string);
76 	int WaitForServer();
77 
78 	/* Private data */
79 	Window Root;
80 	Display *Dpy;
81 	int Scr;
82 	Panel *LoginPanel;
83 	int ServerPID;
84 	const char *DisplayName;
85 	bool serverStarted;
86 
87 #ifdef USE_PAM
88 	PAM::Authenticator pam;
89 #endif
90 #ifdef USE_CONSOLEKIT
91 	Ck::Session ck;
92 #endif
93 
94 	/* Options */
95 	char *DispName;
96 
97 	Cfg *cfg;
98 
99 	Pixmap BackgroundPixmap;
100 
101 	void blankScreen();
102 	Image *image;
103 	Atom BackgroundPixmapId;
104 	void setBackground(const std::string &themedir);
105 
106 	bool firstlogin;
107 	bool daemonmode;
108 	bool force_nodaemon;
109 	/* For testing themes */
110 	char *testtheme;
111 	bool testing;
112 
113 	std::string themeName;
114 	std::string mcookie;
115 
116 	const int mcookiesize;
117 };
118 
119 #endif /* _APP_H_ */
120