app.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. class App {
  27. public:
  28. App(int argc, char** argv);
  29. ~App();
  30. void Run();
  31. int GetServerPID();
  32. void StopServer();
  33. // Lock functions
  34. void GetLock();
  35. void RemoveLock();
  36. private:
  37. void Login();
  38. void Reboot();
  39. void Halt();
  40. void Suspend();
  41. void Console();
  42. void Exit();
  43. void KillAllClients(Bool top);
  44. void RestartServer();
  45. void ReadConfig();
  46. void OpenLog();
  47. void CloseLog();
  48. void HideCursor();
  49. void CreateServerAuth();
  50. char* StrConcat(const char* str1, const char* str2);
  51. void UpdatePid();
  52. bool AuthenticateUser(void);
  53. static std::string findValidRandomTheme(const std::string& set);
  54. static void replaceVariables(std::string& input,
  55. const std::string& var,
  56. const std::string& value);
  57. // Server functions
  58. int StartServer();
  59. int ServerTimeout(int timeout, char *string);
  60. int WaitForServer();
  61. // Private data
  62. Window Root;
  63. Display* Dpy;
  64. int Scr;
  65. Panel* LoginPanel;
  66. int ServerPID;
  67. char* DisplayName;
  68. #ifdef USE_PAM
  69. PAM::Authenticator pam;
  70. #endif
  71. // Options
  72. char* DispName;
  73. Cfg *cfg;
  74. Pixmap BackgroundPixmap;
  75. void blankScreen();
  76. Image* image;
  77. void setBackground(const string& themedir);
  78. bool daemonmode;
  79. // For testing themes
  80. char* testtheme;
  81. bool testing;
  82. std::string themeName;
  83. std::string mcookie;
  84. };
  85. #endif