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