Added in API level 2
public interface

IEmailConfigManager

com.ardic.android.managers.emailconfig.IEmailConfigManager

Class Overview

Provides a set of APIs for e-mail related configurations.

Summary

Constants
int ERROR_ACCESS_DENIED e-mail account add or update error code for the case of the server refused access
int ERROR_AUTHENTICATION e-mail account add or update error code for the case of authentication error
int ERROR_AUTH_REQUIRED e-mail account add or update error code for the case of authentication is required but the server did not support it.
int ERROR_CLIENT_CERTIFICATE_ERROR e-mail account add or update error code for the case of the client SSL certificate specified is invalid
int ERROR_CLIENT_CERTIFICATE_REQUIRED e-mail account add or update error code for the case of a client SSL certificate is required for connections to the server
int ERROR_DUPLICATE_ACCOUNT e-mail account add or update error code for the case of attempt to create duplicate account
int ERROR_GENERAL_SECURITY e-mail account add or update error code for the case of general security failures
int ERROR_NETWORK e-mail account add or update error code for the case of network error
int ERROR_PROTOCOL_VERSION_UNSUPPORTED e-mail account add or update error code for the case of the protocol (or protocol version) isn't supported
int ERROR_TLS_REQUIRED e-mail account add or update error code for the case of the configuration requested TLS but the server did not support it
int ERROR_UNSPECIFIED e-mail account add or update error code for the case of unspecified error
Public Methods
abstract boolean addEmailAccount(EmailConfig config)
Adds an new e-mail account.
abstract boolean deleteEmailAccount(long accId)
Updates an existing e-mail account.
abstract List<EmailConfig> getAllEmailAccounts()
Returns list of e-mail accounts.
abstract EmailConfig getEmailAccount(long accId)
Gets an e-mail account.
abstract long getEmailAccountId(String servername, String domainname, String username)
Returns account ID of the given e-mail settings.
abstract boolean isEmailAccountSetupBlocked()
Returns Block or Unblock state of User Email Account setup.
abstract boolean registerEmailCallback(IEmailConfigCallback callback)
Registers to email config callback to get all email account operation results.
abstract boolean setEmailAccountSetupBlocked(boolean state)
Block or Unblock User Email Account setup.
abstract boolean unregisterEmailCallback(IEmailConfigCallback callback)
Unregisters from email config callback to get email account creation state.
abstract boolean updateEmailAccount(long accId, EmailConfig config)
Updates an existing e-mail account.

Constants

public static final int ERROR_ACCESS_DENIED

Added in API level 2

e-mail account add or update error code for the case of the server refused access

Constant Value: 10 (0x0000000a)

public static final int ERROR_AUTHENTICATION

Added in API level 2

e-mail account add or update error code for the case of authentication error

Constant Value: 2 (0x00000002)

public static final int ERROR_AUTH_REQUIRED

Added in API level 2

e-mail account add or update error code for the case of authentication is required but the server did not support it.

Constant Value: 4 (0x00000004)

public static final int ERROR_CLIENT_CERTIFICATE_ERROR

Added in API level 2

e-mail account add or update error code for the case of the client SSL certificate specified is invalid

Constant Value: 8 (0x00000008)

public static final int ERROR_CLIENT_CERTIFICATE_REQUIRED

Added in API level 2

e-mail account add or update error code for the case of a client SSL certificate is required for connections to the server

Constant Value: 7 (0x00000007)

public static final int ERROR_DUPLICATE_ACCOUNT

Added in API level 2

e-mail account add or update error code for the case of attempt to create duplicate account

Constant Value: 6 (0x00000006)

public static final int ERROR_GENERAL_SECURITY

Added in API level 2

e-mail account add or update error code for the case of general security failures

Constant Value: 5 (0x00000005)

public static final int ERROR_NETWORK

Added in API level 2

e-mail account add or update error code for the case of network error

Constant Value: 1 (0x00000001)

public static final int ERROR_PROTOCOL_VERSION_UNSUPPORTED

Added in API level 2

e-mail account add or update error code for the case of the protocol (or protocol version) isn't supported

Constant Value: 9 (0x00000009)

public static final int ERROR_TLS_REQUIRED

Added in API level 2

e-mail account add or update error code for the case of the configuration requested TLS but the server did not support it

Constant Value: 3 (0x00000003)

public static final int ERROR_UNSPECIFIED

Added in API level 2

e-mail account add or update error code for the case of unspecified error

Constant Value: 0 (0x00000000)

Public Methods

public abstract boolean addEmailAccount (EmailConfig config)

Added in API level 2

Adds an new e-mail account.

Device must be able to connected to the e-mail server. Otherwise operation fails.

Register callback registerEmailCallback(IEmailConfigCallback) to receive all email add/update/delete operation results.

Example usage:

 EmailConfigExchange config = new EmailConfigExchange("My Account",
         "John.Smith", "john.smith@example.com", "123456",
         "mail.example.com", 443, EmailConfig.AUTH_SSL_TLS, "WORK", "Johny",
         "Regards", EmailConfig.INTERVAL_AUTO_PUSH, "14.1",
         EmailConfigExchange.LOOKBACK_ALL, "test_user", true);
 boolean attempt = EmailConfigManager.getInterface(mContext).addEmailAccount((EmailConfig) config);
 

Parameters
config EmailConfig: e-mail account configuration
Returns
boolean true if the add operation started else false. Invalid parameters prevents add operation start.
Throws
AfexException
AfexException

public abstract boolean deleteEmailAccount (long accId)

Added in API level 2

Updates an existing e-mail account.

Register callback registerEmailCallback(IEmailConfigCallback) to receive all email add/update/delete operation results.

Example usage:

 final long accId = EmailConfigManager.getInterface(mContext).getEmailAccountId("mail.example.com",
         "WORK", John.Smith);
 boolean attempt = EmailConfigManager.getInterface(mContext).deleteEmailAccount(accId);
 

Parameters
accId long: Account ID
Returns
boolean true if the operation starts else false. Invalid or non-existent account ID prevents operation start. Also, if any e-mail account add or update operation is in progress delete operation fails.
Throws
AfexException

public abstract List<EmailConfig> getAllEmailAccounts ()

Added in API level 2

Returns list of e-mail accounts. Example usage:

 List<EmailConfig> configList = EmailConfigManager.getInterface(mContext).getAllEmailAccounts();
 for (EmailConfig config : configList) {
     if (config instanceof EmailConfigExchange) {
         ((EmailConfigExchange) config).getProtocolVersion();
     } else if (config instanceof EmailConfigImap) {
         ((EmailConfigImap) config).getImapPathPrefix();
     } else if (config instanceof EmailConfigPop3) {
         ((EmailConfigPop3) config).getOutgoingServerAddress();
     }
 }
 

Returns
List<EmailConfig> List of account configurations.
Throws
AfexException
AfexException

public abstract EmailConfig getEmailAccount (long accId)

Added in API level 2

Gets an e-mail account.

Example usage:

 final long accId = EmailConfigManager.getInterface(mContext).getEmailAccountId("mail.example.com",
         "WORK", John.Smith);
 EmailConfig config = EmailConfigManager.getInterface(mContext).getEmailAccount(accId);
 if (config instanceof EmailConfigExchange) {
     ((EmailConfigExchange) config).getProtocolVersion();
 } else if (config instanceof EmailConfigImap) {
     ((EmailConfigImap) config).getImapPathPrefix();
 } else if (config instanceof EmailConfigPop3) {
     ((EmailConfigPop3) config).getOutgoingServerAddress();
 }
 

Parameters
accId long: Account ID.
Returns
EmailConfig Account configuration.
Throws
AfexException
AfexException

public abstract long getEmailAccountId (String servername, String domainname, String username)

Added in API level 2

public abstract boolean isEmailAccountSetupBlocked ()

Added in API level 2

Returns Block or Unblock state of User Email Account setup.

Returns
boolean true if it is blocked else false
Throws
AfexException

public abstract boolean registerEmailCallback (IEmailConfigCallback callback)

Added in API level 2

Registers to email config callback to get all email account operation results.

All Email operation (add/update/delete) results can be received by registering the callback.

Example usage:

 IEmailConfigCallback iEmailConfigCallback = new IEmailConfigCallback.Stub() {
     // @Override
     public void onEmailConfigAborted() throws RemoteException {
     }
 
     // @Override
     public void onEmailConfigAdded(EmailConfig config) throws RemoteException {
     }
 
     // @Override
     public void onEmailConfigUpdated(EmailConfig config) throws RemoteException {
     }
 
     // @Override
     public void onEmailConfigRemoved(EmailConfig config) throws RemoteException {
     }
 
     // @Override
     public void onEmailConfigAdditionFailed(EmailConfig config, int errorCode)
             throws RemoteException {
     }
 
     // @Override
     public void onEmailConfigUpdateFailed(EmailConfig config, int errorCode) throws RemoteException {
     }
 
     // @Override
     public void onEmailConfigRemoveFailed(EmailConfig config, int errorCode) throws RemoteException {
     }
 };
 
 try {
     EmailConfigManager.getInterface(getApplicationContext()).registerEmailCallback(
             iEmailConfigCallback);
 } catch (AfexException e) {
     e.printStackTrace();
 }
 
Warning: By registering one callback all Email operations can received. if multiple instance of callback is required , each application can registers max 10 callback. So although you register 11. callback, it won't be registered. You should unregister some of them or unregister all of them by passing null parameter as callback.

Parameters
callback IEmailConfigCallback: IEmailConfigCallback to unregister it or null to unregister all of registered callbacks by calling application.
Returns
boolean true if callback registration is succeeded else false
Throws
AfexException

public abstract boolean setEmailAccountSetupBlocked (boolean state)

Added in API level 2

Block or Unblock User Email Account setup.

if it is blocked, user can not setup any e-mail account using Native Email Application.

Parameters
state boolean
Returns
boolean true if it is blocked else false
Throws
AfexException

public abstract boolean unregisterEmailCallback (IEmailConfigCallback callback)

Added in API level 2

Unregisters from email config callback to get email account creation state.

Parameters
callback IEmailConfigCallback: IEmailConfigCallback
Returns
boolean true if callback unregistration is succeeded else false
Throws
AfexException

public abstract boolean updateEmailAccount (long accId, EmailConfig config)

Added in API level 2

Updates an existing e-mail account.

Device must be able to connected to the e-mail server. Otherwise operation fails.

Register callback registerEmailCallback(IEmailConfigCallback) to receive all email add/update/delete operation results.

Example usage:

 EmailConfigExchange config = new EmailConfigExchange("My New Account",
         "John.Smith", "john.smith@example.com", "654321",
         "mail.example.com", 443, EmailConfig.AUTH_SSL_TLS, "WORK", "Johny",
         "Regards", EmailConfig.INTERVAL_AUTO_PUSH, "14.1",
         EmailConfigExchange.LOOKBACK_ALL, "test_user", true);
 config.setPwd("MoreSecurePassword123456");
 // get email account id
 final long accId = EmailConfigManager.getInterface(mContext).getEmailAccountId("mail.example.com",
         "WORK", John.Smith);
 // update account password
 boolean attempt = EmailConfigManager.getInterface(mContext).updateEmailAccount(accId,
         (EmailConfig) config);
 

Parameters
accId long: Account ID
config EmailConfig: new e-mail account configuration.
Returns
boolean true if the operation starts else false. Invalid parameters prevents update operation start.
Throws
AfexException
AfexException