input.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* SLiM - Simple Login Manager
  2. Copyright (C) 1997, 1998 Per Liden
  3. Copyright (C) 2004-05 Simone Rota <sip@varlock.com>
  4. Copyright (C) 2004-05 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 _INPUT_H_
  11. #define _INPUT_H_
  12. #include <X11/Xlib.h>
  13. #include <X11/keysym.h>
  14. #include <X11/Xft/Xft.h>
  15. #include <pwd.h>
  16. #include <unistd.h>
  17. #include <string>
  18. #include <ctype.h>
  19. #include <iostream>
  20. #include "const.h"
  21. #include "cfg.h"
  22. #ifdef HAVE_SHADOW
  23. #include <shadow.h>
  24. #endif
  25. class Input {
  26. public:
  27. Input(Cfg* c);
  28. ~Input();
  29. char Key(char ascii, KeySym keysym, bool singleInputMode);
  30. int GetAction();
  31. int GetField();
  32. char* GetName();
  33. char* GetHiddenPasswd();
  34. struct passwd* GetPasswdStruct();
  35. void Reset();
  36. void ResetName();
  37. void ResetPassword();
  38. void SetName(string name);
  39. private:
  40. void Add(char ascii);
  41. char DeleteLast();
  42. int Correct();
  43. int SpecialWanted();
  44. int SpecialCorrect(int special);
  45. Cfg* cfg;
  46. char NameBuffer[INPUT_MAXLENGTH_NAME];
  47. char PasswdBuffer[INPUT_MAXLENGTH_PASSWD];
  48. char HiddenPasswdBuffer[INPUT_MAXLENGTH_PASSWD];
  49. int Action;
  50. int Field;
  51. };
  52. #endif