1 /*! 2 * \file 3 * \ingroup interface_login 4 * \brief Functions to handle the login. 5 */ 6 #ifndef __LOGINWIN_H__ 7 #define __LOGINWIN_H__ 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 // How long a username is allowed to be. This define allows for the trailing NULL 14 #define MAX_USERNAME_LENGTH (15 + 1) 15 #define MIN_USERNAME_LEN 3 16 17 extern int login_root_win; /*!< ID for the login root window */ 18 extern int login_text; /*!< ID for the background texture */ 19 extern char active_username_str[MAX_USERNAME_LENGTH]; /*!< the username of the actor */ 20 extern char active_password_str[MAX_USERNAME_LENGTH]; /*!< the password of the actor */ 21 22 #define VALID_PASSWORD_CHAR(ch) (ch>=33 && ch<126) 23 #define MAX_PASSWORD_LEN MAX_USERNAME_LENGTH 24 #define MIN_PASSWORD_LEN 4 25 26 /*! 27 * \name Getters and setters for current username and password. 28 */ 29 /*! @{ */ 30 const char * get_username(void); 31 const char * get_lowercase_username(void); 32 const char * get_password(void); 33 void set_username(const char * new_username); 34 void set_password(const char * new_password); 35 int valid_username_password(void); 36 /*! @} */ 37 38 /*! 39 * \ingroup interface_login 40 * \brief Loads the textures for the opening interface. 41 * 42 * Loads the textures for the opening interface by calling \ref load_texture_cache with the appropriate bitmaps. 43 * 44 * \callgraph 45 */ 46 void init_login_screen (void); 47 48 /*! 49 * \ingroup interface_login 50 * \brief Sets the error string used when a login error occurs. 51 * 52 * Sets the error string used when a login error occurs to be \a msg. 53 * 54 * \param msg the message for the login error 55 * \param len the length of \a msg 56 * \param print_err if non-zero, prefix the message with an error string 57 * \callgraph 58 */ 59 void set_login_error (const char *msg, int len, int print_err); 60 61 /*! 62 * \ingroup interface_login 63 * \brief Creates the root window for the login interface. 64 * 65 * Creates the root window for the login interface using the given \a width and \a height, if it was not created before. This functions also sets the event handlers for the \ref ELW_HANDLER_DISPLAY, \ref ELW_HANDLER_MOUSEOVER, \ref ELW_HANDLER_CLICK, \ref ELW_HANDLER_KEYPRESS and \ref ELW_HANDLER_RESIZE events. 66 * 67 * \param width the width of the login window 68 * \param height the height of the login window 69 * \callgraph 70 * 71 * \pre If \ref login_root_win >= 0, this function won't perform any action. 72 */ 73 void create_login_root_window (int width, int height); 74 75 #ifdef __cplusplus 76 } // extern "C" 77 #endif 78 79 #endif // def __LOGINWIN_H__ 80