app.h 2.3 KB

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