1 /** 2 * @file 3 * Connection Credentials 4 * 5 * @authors 6 * Copyright (C) 2000-2005,2008 Brendan Cully <brendan@kublai.com> 7 * 8 * @copyright 9 * This program is free software: you can redistribute it and/or modify it under 10 * the terms of the GNU General Public License as published by the Free Software 11 * Foundation, either version 2 of the License, or (at your option) any later 12 * version. 13 * 14 * This program is distributed in the hope that it will be useful, but WITHOUT 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 * details. 18 * 19 * You should have received a copy of the GNU General Public License along with 20 * this program. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 #ifndef MUTT_CONN_CONNACCOUNT_H 24 #define MUTT_CONN_CONNACCOUNT_H 25 26 #include <stdbool.h> 27 #include <stdint.h> 28 29 /** 30 * enum ConnAccountField - Login credentials 31 */ 32 enum ConnAccountField 33 { 34 MUTT_CA_HOST = 1, ///< Server name 35 MUTT_CA_LOGIN, ///< Login name 36 MUTT_CA_USER, ///< User name 37 MUTT_CA_PASS, ///< Password 38 MUTT_CA_OAUTH_CMD, ///< OAuth refresh command 39 }; 40 41 typedef uint8_t MuttAccountFlags; ///< Flags, Which ConnAccount fields are initialised, e.g. #MUTT_ACCT_PORT 42 #define MUTT_ACCT_NO_FLAGS 0 ///< No flags are set 43 #define MUTT_ACCT_PORT (1 << 0) ///< Port field has been set 44 #define MUTT_ACCT_USER (1 << 1) ///< User field has been set 45 #define MUTT_ACCT_LOGIN (1 << 2) ///< Login field has been set 46 #define MUTT_ACCT_PASS (1 << 3) ///< Password field has been set 47 #define MUTT_ACCT_SSL (1 << 4) ///< Account uses SSL/TLS 48 49 /** 50 * struct ConnAccount - Login details for a remote server 51 */ 52 struct ConnAccount 53 { 54 char host[128]; ///< Server to login to 55 char login[128]; ///< Login name 56 char user[128]; ///< Username 57 char pass[256]; ///< Password 58 unsigned short port; ///< Port to connect to 59 unsigned char type; ///< Connection type, e.g. #MUTT_ACCT_TYPE_IMAP 60 MuttAccountFlags flags; ///< Which fields are initialised, e.g. #MUTT_ACCT_USER 61 const char *service; ///< Name of the service, e.g. "imap" 62 63 /** 64 * get_field - Function to get some login credentials 65 * @param field Field to get, e.g. #MUTT_CA_PASS 66 * @retval ptr Requested string 67 */ 68 const char *(*get_field)(enum ConnAccountField field, void *gf_data); 69 70 void *gf_data; ///< Private data to pass to get_field() 71 }; 72 73 int mutt_account_getlogin (struct ConnAccount *account); 74 char *mutt_account_getoauthbearer(struct ConnAccount *account, bool xoauth2); 75 int mutt_account_getpass (struct ConnAccount *account); 76 int mutt_account_getuser (struct ConnAccount *account); 77 void mutt_account_unsetpass (struct ConnAccount *account); 78 79 #endif /* MUTT_CONN_CONNACCOUNT_H */ 80