app.h 2.4 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 <signal.h>
  14. #include <unistd.h>
  15. #include <sys/wait.h>
  16. #include <errno.h>
  17. #include <setjmp.h>
  18. #include <stdlib.h>
  19. #include <iostream>
  20. #include "panel.h"
  21. #include "cfg.h"
  22. #include "image.h"
  23. #ifdef USE_PAM
  24. #include "PAM.h"
  25. #endif
  26. #ifdef USE_CONSOLEKIT
  27. #include "Ck.h"
  28. #endif
  29. class App {
  30. public:
  31. App(int argc, char** argv);
  32. ~App();
  33. void Run();
  34. int GetServerPID();
  35. void RestartServer();
  36. void StopServer();
  37. // Lock functions
  38. void GetLock();
  39. void RemoveLock();
  40. bool isServerStarted();
  41. private:
  42. void Login();
  43. void Reboot();
  44. void Halt();
  45. void Suspend();
  46. void Console();
  47. void Exit();
  48. void KillAllClients(Bool top);
  49. void ReadConfig();
  50. void OpenLog();
  51. void CloseLog();
  52. void HideCursor();
  53. void CreateServerAuth();
  54. char* StrConcat(const char* str1, const char* str2);
  55. void UpdatePid();
  56. bool AuthenticateUser(bool focuspass);
  57. static std::string findValidRandomTheme(const std::string& set);
  58. static void replaceVariables(std::string& input,
  59. const std::string& var,
  60. const std::string& value);
  61. // Server functions
  62. int StartServer();
  63. int ServerTimeout(int timeout, char *string);
  64. int WaitForServer();
  65. // Private data
  66. Window Root;
  67. Display* Dpy;
  68. int Scr;
  69. Panel* LoginPanel;
  70. int ServerPID;
  71. const char* DisplayName;
  72. bool serverStarted;
  73. #ifdef USE_PAM
  74. PAM::Authenticator pam;
  75. #endif
  76. #ifdef USE_CONSOLEKIT
  77. Ck::Session ck;
  78. #endif
  79. // Options
  80. char* DispName;
  81. Cfg *cfg;
  82. Pixmap BackgroundPixmap;
  83. void blankScreen();
  84. Image* image;
  85. void setBackground(const std::string& themedir);
  86. bool firstlogin;
  87. bool daemonmode;
  88. bool force_nodaemon;
  89. // For testing themes
  90. char* testtheme;
  91. bool testing;
  92. std::string themeName;
  93. std::string mcookie;
  94. const int mcookiesize;
  95. };
  96. #endif