com.vodafone360.people.database.tables
Class StateTable

java.lang.Object
  extended by com.vodafone360.people.database.tables.StateTable

public abstract class StateTable
extends java.lang.Object

Contains all the functionality related to the state database table. This table is used to persist individual setting data. The table always has only one record. This class is never instantiated hence all methods must be static.

Version:
%I%, %G%

Nested Class Summary
private static class StateTable.Field
          An enumeration of all the field names in the database.
 
Field Summary
private static int PRIMARY_STATE_KEY_VALUE
          The state table only has one record with the primary key set to the following value.
private static java.lang.String TABLE_NAME
          Name of the table as it appears in the database.
 
Constructor Summary
private StateTable()
          Private constructor to prevent instantiation.
 
Method Summary
static void create(SQLiteDatabase writableDb)
          Create Settings Table and add a record with default setting values.
static java.lang.Integer fetchContactRevision(SQLiteDatabase readableDb)
          Fetches the current contact revision for the server sync.
static long fetchLatestMmsTime(SQLiteDatabase readableDb)
          Fetches the timestamp of the latest MMS timeline activity that was synced.
static long fetchLatestPhoneCallTime(SQLiteDatabase readableDb)
          Fetches the timestamp of the latest phone call timeline activity that was synced.
static long fetchLatestSmsTime(SQLiteDatabase readableDb)
          Fetches the timestamp of the latest SMS timeline activity that was synced.
static long fetchLatestStatusUpdateTime(SQLiteDatabase readableDb)
          Fetches the timestamp of the latest status activity that was synced.
static ServiceStatus fetchLogonCredentials(LoginDetails details, SQLiteDatabase readableDb)
          Fetches cached user login credentials (without encryption information).
static ServiceStatus fetchLogonCredentialsAndPublicKey(LoginDetails details, PublicKeyDetails pubKeyDetails, SQLiteDatabase readableDb)
          Fetches cached user login credentials (with encryption information).
static boolean fetchMeProfileAvatarChangedFlag(SQLiteDatabase readableDb)
          Fetches the "me profile avatar changed flag" from the state table.
static boolean fetchMeProfileChangedFlag(SQLiteDatabase readableDb)
          Fetches the "me profile changed" flag from the database.
static java.lang.Long fetchMeProfileId(SQLiteDatabase readableDb)
          Fetches the local contact ID for the me profile (which is stored in the contacts table with the other contacts).
static long fetchMeProfileRevision(SQLiteDatabase readableDb)
          Fetches the current me profile revision for the server sync.
static long fetchOldestMmsTime(SQLiteDatabase readableDb)
          Fetches the timestamp of the oldest MMS status activity that was synced.
static long fetchOldestPhoneCallTime(SQLiteDatabase readableDb)
          Fetches the timestamp of the oldest phone call timeline activity that was synced.
static long fetchOldestSmsTime(SQLiteDatabase readableDb)
          Fetches the timestamp of the oldest SMS that was synced.
static long fetchOldestStatusUpdate(SQLiteDatabase readableDb)
          Fetches the timestamp of the oldest status activity that was synced.
static PersistSettings fetchOption(PersistSettings.Option option, SQLiteDatabase readableDb)
          Fetches an option from the settings table.
static AuthSessionHolder fetchSession(SQLiteDatabase readableDb)
          Fetches the current session from the database.
static boolean isRegistrationComplete(SQLiteDatabase readableDb)
          Fetch value of registration complete flag from database.
static boolean modifyContactRevision(java.lang.Integer revision, SQLiteDatabase writableDb)
          Stores a new server contact revision in the database.
static ServiceStatus modifyCredentials(LoginDetails details, SQLiteDatabase writableDb)
          Modify cached user credentials settings (without encryption information).
static ServiceStatus modifyCredentialsAndPublicKey(LoginDetails details, PublicKeyDetails pubKeyDetails, SQLiteDatabase writableDb)
          Modify cached user credentials settings (without encryption information).
static ServiceStatus modifyLatestMmsTime(long value, SQLiteDatabase writableDb)
          Modifies the timestamp for the last MMS timeline activity that has been synced.
static ServiceStatus modifyLatestPhoneCallTime(long value, SQLiteDatabase writableDb)
          Modifies the timestamp for the last phone call activity that has been synced.
static ServiceStatus modifyLatestSmsTime(long value, SQLiteDatabase writableDb)
          Modifies the timestamp for the last SMS timeline activity that has been synced.
static ServiceStatus modifyLatestStatusUpdateTime(long value, SQLiteDatabase writableDb)
          Modifies the timestamp for the last status activity that has been synced.
static ServiceStatus modifyMeProfileChangedFlag(boolean myContactChanged, SQLiteDatabase writableDb)
          Sets the "me profile changed" flag in the database to the given value.
static ServiceStatus modifyMeProfileID(java.lang.Long myContactID, SQLiteDatabase writableDb)
          Sets the me profile ID.
static boolean modifyMeProfileRevision(long revision, SQLiteDatabase writableDb)
          Stores a new server me profile revision in the database.
static ServiceStatus modifyOldestMmsTime(long value, SQLiteDatabase writableDb)
          Modifies the timestamp for the oldest MMS activity that has been synced.
static ServiceStatus modifyOldestPhoneCallTime(long value, SQLiteDatabase writableDb)
          Modifies the timestamp for the oldest phone call timeline activity that has been synced.
static ServiceStatus modifyOldestSmsTime(long value, SQLiteDatabase writableDb)
          Modifies the timestamp for the oldest SMS activity that has been synced.
static ServiceStatus modifyOldestStatusTime(long value, SQLiteDatabase writableDb)
          Modifies the timestamp for the oldest status activity that has been synced.
static ServiceStatus setOption(PersistSettings setting, SQLiteDatabase writableDb)
          Stores a persist setting option in the database.
static boolean setRegistrationComplete(boolean complete, SQLiteDatabase writableDb)
          Set registration complete flag.
static ServiceStatus setSession(AuthSessionHolder session, SQLiteDatabase writableDb)
          Stores the latest session in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_NAME

private static final java.lang.String TABLE_NAME
Name of the table as it appears in the database.

See Also:
Constant Field Values

PRIMARY_STATE_KEY_VALUE

private static final int PRIMARY_STATE_KEY_VALUE
The state table only has one record with the primary key set to the following value.

See Also:
Constant Field Values
Constructor Detail

StateTable

private StateTable()
Private constructor to prevent instantiation.

Method Detail

create

public static void create(SQLiteDatabase writableDb)
Create Settings Table and add a record with default setting values.

Parameters:
writableDb - A writable SQLite database.

fetchLogonCredentials

public static ServiceStatus fetchLogonCredentials(LoginDetails details,
                                                  SQLiteDatabase readableDb)
Fetches cached user login credentials (without encryption information).

Parameters:
details - An empty LoginDetails object to be filled
readableDb - Readable SQLite database for fetching the information
Returns:
SUCCESS or a suitable error code

fetchLogonCredentialsAndPublicKey

public static ServiceStatus fetchLogonCredentialsAndPublicKey(LoginDetails details,
                                                              PublicKeyDetails pubKeyDetails,
                                                              SQLiteDatabase readableDb)
Fetches cached user login credentials (with encryption information).

Parameters:
details - An empty LoginDetails object to be filled
pubKeyDetails - An empty PublicKeyDetails object to be filled
readableDb - Readable SQLite database for fetching the information
Returns:
SUCCESS or a suitable error code

modifyCredentials

public static ServiceStatus modifyCredentials(LoginDetails details,
                                              SQLiteDatabase writableDb)
Modify cached user credentials settings (without encryption information).

Parameters:
details - The new credentials.
writableDb - Writable SQLite database
Returns:
SUCCESS or a suitable error code

modifyCredentialsAndPublicKey

public static ServiceStatus modifyCredentialsAndPublicKey(LoginDetails details,
                                                          PublicKeyDetails pubKeyDetails,
                                                          SQLiteDatabase writableDb)
Modify cached user credentials settings (without encryption information).

Parameters:
details - The new credentials.
pubKeyDetails - The new key details.
writableDb - Writable SQLite database
Returns:
SUCCESS or a suitable error code

setRegistrationComplete

public static boolean setRegistrationComplete(boolean complete,
                                              SQLiteDatabase writableDb)
Set registration complete flag.

Parameters:
complete - The flag value (true or false)
writableDb - Writable SQLite database
Returns:
true if successful, false otherwise

isRegistrationComplete

public static boolean isRegistrationComplete(SQLiteDatabase readableDb)
Fetch value of registration complete flag from database.

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
true if registration is complete, false if registration is not complete or a database error has occurred.

fetchContactRevision

public static java.lang.Integer fetchContactRevision(SQLiteDatabase readableDb)
Fetches the current contact revision for the server sync.

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
The revision number or null if an error occurs.

modifyContactRevision

public static boolean modifyContactRevision(java.lang.Integer revision,
                                            SQLiteDatabase writableDb)
Stores a new server contact revision in the database.

Parameters:
revision - New revision number
writableDb - Writable SQLite database for storing the information
Returns:
true if successful, false otherwise

fetchOption

public static PersistSettings fetchOption(PersistSettings.Option option,
                                          SQLiteDatabase readableDb)
Fetches an option from the settings table.

Parameters:
option - Specifies which option is required
readableDb - Readable SQLite database for fetching the information
Returns:
A PersistSettings object containing the option data if successful, null otherwise.

setOption

public static ServiceStatus setOption(PersistSettings setting,
                                      SQLiteDatabase writableDb)
Stores a persist setting option in the database.

Parameters:
setting - The setting to store. Must have an option set with data.
writableDb - Writable SQLite database for storing the information
Returns:
SUCCESS or a suitable error code

fetchSession

public static AuthSessionHolder fetchSession(SQLiteDatabase readableDb)
Fetches the current session from the database.

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
The session object or null if the session was not available.

setSession

public static ServiceStatus setSession(AuthSessionHolder session,
                                       SQLiteDatabase writableDb)
Stores the latest session in the database.

Parameters:
session - The session object to store.
writableDb - Writable SQLite database for storing the information
Returns:
SUCCESS or a suitable error code.

fetchMeProfileId

public static java.lang.Long fetchMeProfileId(SQLiteDatabase readableDb)
Fetches the local contact ID for the me profile (which is stored in the contacts table with the other contacts).

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
The local contact ID value or null if the user profile has not yet been synced from the server.

modifyMeProfileID

public static ServiceStatus modifyMeProfileID(java.lang.Long myContactID,
                                              SQLiteDatabase writableDb)
Sets the me profile ID. This should only be called once when the me profile is first synced from the server.

Parameters:
myContactID - The local contact ID of the me profile, or null if the me profile is deleted (the latter is currently possibly by the UI).
writableDb - Writable SQLite database for storing the information
Returns:
SUCCESS or a suitable error code.

fetchMeProfileChangedFlag

public static boolean fetchMeProfileChangedFlag(SQLiteDatabase readableDb)
Fetches the "me profile changed" flag from the database. This flag is used to trigger a contact sync with the server.

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
true if the me profile has changed, false if the me profile hasn't changed or a database error has occurred.

modifyMeProfileChangedFlag

public static ServiceStatus modifyMeProfileChangedFlag(boolean myContactChanged,
                                                       SQLiteDatabase writableDb)
Sets the "me profile changed" flag in the database to the given value.

Parameters:
myContactChanged - The new value for the flag
writableDb - Writable SQLite database for storing the information
Returns:
SUCCESS or a suitable error code.

fetchLatestStatusUpdateTime

public static long fetchLatestStatusUpdateTime(SQLiteDatabase readableDb)
Fetches the timestamp of the latest status activity that was synced. Used to keep track of which activities have already been added.

Parameters:
readableDb - Readable SQLite database for fetching the information.
Returns:
The timestamp in milliseconds, or 0 if the is a problem.

fetchOldestStatusUpdate

public static long fetchOldestStatusUpdate(SQLiteDatabase readableDb)
Fetches the timestamp of the oldest status activity that was synced. Used to keep track of which activities have already been added.

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
The timestamp in milliseconds

fetchOldestSmsTime

public static long fetchOldestSmsTime(SQLiteDatabase readableDb)
Fetches the timestamp of the oldest SMS that was synced. Used to keep track of which activities have already been added.

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
The timestamp in milliseconds

fetchOldestMmsTime

public static long fetchOldestMmsTime(SQLiteDatabase readableDb)
Fetches the timestamp of the oldest MMS status activity that was synced. Used to keep track of which activities have already been added.

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
The timestamp in milliseconds

fetchLatestPhoneCallTime

public static long fetchLatestPhoneCallTime(SQLiteDatabase readableDb)
Fetches the timestamp of the latest phone call timeline activity that was synced. Used to keep track of which activities have already been added.

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
The timestamp in milliseconds, or 0 if there was a problem.

fetchLatestSmsTime

public static long fetchLatestSmsTime(SQLiteDatabase readableDb)
Fetches the timestamp of the latest SMS timeline activity that was synced. Used to keep track of which activities have already been added.

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
The timestamp in milliseconds

fetchLatestMmsTime

public static long fetchLatestMmsTime(SQLiteDatabase readableDb)
Fetches the timestamp of the latest MMS timeline activity that was synced. Used to keep track of which activities have already been added.

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
The timestamp in milliseconds

fetchOldestPhoneCallTime

public static long fetchOldestPhoneCallTime(SQLiteDatabase readableDb)
Fetches the timestamp of the oldest phone call timeline activity that was synced. Used to keep track of which activities have already been added.

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
The timestamp in milliseconds

modifyLatestStatusUpdateTime

public static ServiceStatus modifyLatestStatusUpdateTime(long value,
                                                         SQLiteDatabase writableDb)
Modifies the timestamp for the last status activity that has been synced.

Parameters:
value - The new timestamp value (in milliseconds)
writableDb - Writable SQLite database for storing the information
Returns:
SUCCESS or a suitable error code.

modifyOldestStatusTime

public static ServiceStatus modifyOldestStatusTime(long value,
                                                   SQLiteDatabase writableDb)
Modifies the timestamp for the oldest status activity that has been synced.

Parameters:
value - The new timestamp value (in milliseconds)
writableDb - Writable SQLite database for storing the information
Returns:
SUCCESS or a suitable error code.

modifyOldestSmsTime

public static ServiceStatus modifyOldestSmsTime(long value,
                                                SQLiteDatabase writableDb)
Modifies the timestamp for the oldest SMS activity that has been synced.

Parameters:
value - The new timestamp value (in milliseconds)
writableDb - Writable SQLite database for storing the information
Returns:
SUCCESS or a suitable error code.

modifyOldestMmsTime

public static ServiceStatus modifyOldestMmsTime(long value,
                                                SQLiteDatabase writableDb)
Modifies the timestamp for the oldest MMS activity that has been synced.

Parameters:
value - The new timestamp value (in milliseconds)
writableDb - Writable SQLite database for storing the information
Returns:
SUCCESS or a suitable error code.

modifyLatestPhoneCallTime

public static ServiceStatus modifyLatestPhoneCallTime(long value,
                                                      SQLiteDatabase writableDb)
Modifies the timestamp for the last phone call activity that has been synced.

Parameters:
value - The new timestamp value (in milliseconds)
writableDb - Writable SQLite database for storing the information
Returns:
SUCCESS or a suitable error code.

modifyLatestSmsTime

public static ServiceStatus modifyLatestSmsTime(long value,
                                                SQLiteDatabase writableDb)
Modifies the timestamp for the last SMS timeline activity that has been synced.

Parameters:
value - The new timestamp value (in milliseconds)
writableDb - Writable SQLite database for storing the information
Returns:
SUCCESS or a suitable error code.

modifyLatestMmsTime

public static ServiceStatus modifyLatestMmsTime(long value,
                                                SQLiteDatabase writableDb)
Modifies the timestamp for the last MMS timeline activity that has been synced.

Parameters:
value - The new timestamp value (in milliseconds)
writableDb - Writable SQLite database for storing the information
Returns:
SUCCESS or a suitable error code.

modifyOldestPhoneCallTime

public static ServiceStatus modifyOldestPhoneCallTime(long value,
                                                      SQLiteDatabase writableDb)
Modifies the timestamp for the oldest phone call timeline activity that has been synced.

Parameters:
value - The new timestamp value (in milliseconds)
writableDb - Writable SQLite database for storing the information
Returns:
SUCCESS or a suitable error code.

fetchMeProfileRevision

public static long fetchMeProfileRevision(SQLiteDatabase readableDb)
Fetches the current me profile revision for the server sync.

Parameters:
readableDb - Readable SQLite database for fetching the information
Returns:
The revision number or null if an error occurs.

modifyMeProfileRevision

public static boolean modifyMeProfileRevision(long revision,
                                              SQLiteDatabase writableDb)
Stores a new server me profile revision in the database.

Parameters:
revision - New revision number
writableDb - Writable SQLite database for storing the information
Returns:
true if successful, false otherwise

fetchMeProfileAvatarChangedFlag

public static boolean fetchMeProfileAvatarChangedFlag(SQLiteDatabase readableDb)
Fetches the "me profile avatar changed flag" from the state table.

Parameters:
readableDb - The SQLite database with read access
Returns:
true if the avatar has changed, false otherwise


JavaDoc