2017-02-28 15:13:33 +01:00
|
|
|
/**
|
|
|
|
* Account Settings - a small library to retrieve & guess settings for e-mail and other accounts
|
|
|
|
*
|
|
|
|
* (C) 2017 pEp Security S.A. All rights reserved.
|
|
|
|
*
|
|
|
|
* License: See LICENSE.TXT
|
|
|
|
*
|
|
|
|
* This is the public C API for libAccountSettings.
|
|
|
|
* There is a C++ API in account_settings.hh
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-05-23 13:38:58 +02:00
|
|
|
#ifndef PEP_ACCOUNT_SETTINGS_C_H_
|
|
|
|
#define PEP_ACCOUNT_SETTINGS_C_H_
|
|
|
|
|
|
|
|
#include "account_settings_common.h"
|
2017-02-28 15:13:33 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-03-30 15:26:37 +02:00
|
|
|
//! from user-level code: just an opaque handle to access the account settings
|
2017-02-28 15:13:33 +01:00
|
|
|
struct AccountSettings;
|
|
|
|
|
2017-03-30 15:26:37 +02:00
|
|
|
//! from user-level code: just an opaque handle to access certain server parameters (hostname, port number, access methods etc.)
|
|
|
|
struct AS_Server;
|
2017-03-07 12:16:05 +01:00
|
|
|
|
2017-03-30 15:26:37 +02:00
|
|
|
|
|
|
|
/** Release any memory that might be occupied by dynamically created AccountSetting objects.
|
|
|
|
* Don't access the pointee after this call!
|
|
|
|
* @param account_settings a pointer to an object created by get_account_settings() or a NULL pointer (which is a safe no-op).
|
|
|
|
*/
|
2017-04-28 15:51:29 +02:00
|
|
|
void free_account_settings(const struct AccountSettings* account_settings);
|
2017-03-07 12:16:05 +01:00
|
|
|
|
2017-05-03 17:14:19 +02:00
|
|
|
/** get account settings - the main API function. @see AS_FLAGS
|
2017-02-28 15:13:33 +01:00
|
|
|
*
|
|
|
|
* @param accountName the accountName, e.g. an e-mail address. MUST NOT be NULL.
|
|
|
|
* @param provider the name of a provider. May be NULL if unknown. @see get_known_providers()
|
2017-05-03 17:14:19 +02:00
|
|
|
* @param flags the flags @see AS_FLAGS
|
2017-02-28 15:13:33 +01:00
|
|
|
* @param credentials additional credentials that might be necessary to retrieve the account settings. Depends on AS_FLAGS, may be NULL.
|
2017-03-30 15:26:37 +02:00
|
|
|
* @return the requested settings or NULL (only in case of out-of-memory)
|
|
|
|
* Don't forget to call free_account_settings() when the result is no longer needed. free_account_settings(NULL) is a safe no-op.
|
|
|
|
*/
|
2017-04-28 15:51:29 +02:00
|
|
|
const struct AccountSettings* get_account_settings(const char* accountName, const char* provider, AS_FLAGS flags, const void* credentials);
|
2017-03-30 15:26:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
/** get the status of the account_settings
|
|
|
|
*
|
|
|
|
* @param account_settings the account settings your want to get the status for
|
|
|
|
* @return the status. Only if it is AS_OK the other query functions will return useful results!
|
2017-02-28 15:13:33 +01:00
|
|
|
*/
|
2017-05-03 17:08:09 +02:00
|
|
|
AS_STATUS AS_get_status(const struct AccountSettings* account_settings);
|
2017-02-28 15:13:33 +01:00
|
|
|
|
|
|
|
|
2018-01-31 09:04:37 +01:00
|
|
|
/** get the privder id string of the account_settings
|
|
|
|
*
|
|
|
|
* @param account_settings the account settings your want to get provider id
|
|
|
|
* @return the provider id, if any. Might be NULL or empty string.
|
|
|
|
The pointer points to internal r/o data in accountSettings, do not delete it!
|
|
|
|
*/
|
|
|
|
const char* AS_get_provider_id(const struct AccountSettings* account_settings);
|
|
|
|
|
|
|
|
|
2017-03-30 15:26:37 +02:00
|
|
|
/** get the server settings for "incoming" messages (e.g. IMAP or POP3)
|
|
|
|
* @param accountSettings guess what
|
|
|
|
* @return the server for incoming messages associated with the accountSettings.
|
|
|
|
The pointer points to internal r/o data in accountSettings, do not delete it!
|
|
|
|
*/
|
2017-05-03 17:14:19 +02:00
|
|
|
const struct AS_Server* AS_get_incoming(const struct AccountSettings* accountSettings);
|
2017-03-30 15:26:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
/** get the server settings for "outgoing" messages (e.g. SMTP)
|
|
|
|
* @param accountSettings guess what
|
|
|
|
* @return the server for outgoing messages associated with the accountSettings.
|
|
|
|
The pointer points to internal r/o data in accountSettings, do not delete it!
|
|
|
|
*/
|
2017-05-03 17:14:19 +02:00
|
|
|
const struct AS_Server* AS_get_outgoing(const struct AccountSettings* accountSettings);
|
2017-03-30 15:26:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
/** get the hostname of the server
|
|
|
|
* @param server guess what
|
|
|
|
* @return the hostname (DNS name or IP literal) of the server.
|
|
|
|
The pointer points to internal r/o data in accountSettings, do not delete it!
|
|
|
|
*/
|
2017-04-28 15:51:29 +02:00
|
|
|
const char* AS_get_hostname(const struct AS_Server* server);
|
2017-03-30 15:26:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
/** get the port number where the server provides its service
|
|
|
|
* @param server guess what
|
|
|
|
* @return the numerical port number
|
|
|
|
*/
|
2017-04-28 15:51:29 +02:00
|
|
|
int AS_get_port(const struct AS_Server* server);
|
2017-03-30 15:26:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
/** get the access method that is provided by the server
|
|
|
|
* @param server guess what
|
|
|
|
* @return the combined access method (protocol, socket type, authentication type)
|
|
|
|
*/
|
2017-04-28 15:51:29 +02:00
|
|
|
AS_ACCESS AS_get_access_method(const struct AS_Server* server);
|
2017-03-30 15:26:37 +02:00
|
|
|
|
|
|
|
|
2017-05-12 22:03:23 +02:00
|
|
|
/** get the username for authentication at the server
|
2017-03-30 15:26:37 +02:00
|
|
|
* @param server guess what
|
2017-05-12 22:03:23 +02:00
|
|
|
* @return the user name/login name
|
2017-03-30 15:26:37 +02:00
|
|
|
*/
|
2017-05-12 22:03:23 +02:00
|
|
|
const char* AS_get_username(const struct AS_Server* server);
|
2017-03-07 12:16:05 +01:00
|
|
|
|
|
|
|
|
2017-02-28 15:13:33 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // end of extern "C"
|
|
|
|
#endif
|
|
|
|
|
2017-05-23 13:38:58 +02:00
|
|
|
#endif // PEP_ACCOUNT_SETTINGS_C_H_
|