2013-06-14 00:14:50 -04:00
using System ;
2013-08-01 16:20:39 -04:00
using Android.App ;
2013-07-25 08:47:05 -04:00
using System.IO ;
2013-06-14 00:14:50 -04:00
using Android.Content ;
2013-06-25 15:27:41 -04:00
using Android.OS ;
2013-11-17 01:17:15 -05:00
using KeePassLib.Keys ;
2013-06-14 00:14:50 -04:00
using KeePassLib.Serialization ;
2013-07-09 03:59:17 -04:00
using keepass2android.Io ;
2013-06-14 00:14:50 -04:00
namespace keepass2android
{
2013-06-15 16:02:48 -04:00
/// <summary>
/// Interface through which Activities and the logic layer can access some app specific functionalities and Application static data
/// </summary>
/// This also contains methods which are UI specific and should be replacable for testing.
2013-06-14 00:14:50 -04:00
public interface IKp2aApp
{
2013-07-25 08:47:05 -04:00
/// <summary>
/// Locks the currently open database, quicklocking if available (unless false is passed for allowQuickUnlock)
/// </summary>
void LockDatabase ( bool allowQuickUnlock = true ) ;
2013-06-15 16:02:48 -04:00
/// <summary>
2013-07-25 08:47:05 -04:00
/// Loads the specified data as the currently open database, as unlocked.
2013-06-15 16:02:48 -04:00
/// </summary>
2013-11-17 01:17:15 -05:00
void LoadDatabase ( IOConnectionInfo ioConnectionInfo , MemoryStream memoryStream , CompositeKey compKey , ProgressDialogStatusLogger statusLogger ) ;
2013-06-15 16:02:48 -04:00
/// <summary>
/// Returns the current database
/// </summary>
2013-06-14 00:14:50 -04:00
Database GetDb ( ) ;
2013-06-15 16:02:48 -04:00
/// <summary>
/// Tell the app that the file from ioc was opened with keyfile.
/// </summary>
2013-06-14 00:14:50 -04:00
void StoreOpenedFileAsRecent ( IOConnectionInfo ioc , string keyfile ) ;
2013-06-15 16:02:48 -04:00
/// <summary>
/// Creates a new database and returns it
/// </summary>
2013-06-14 00:14:50 -04:00
Database CreateNewDatabase ( ) ;
2013-06-15 16:02:48 -04:00
/// <summary>
/// Returns the user-displayable string identified by stringKey
/// </summary>
2013-06-14 00:14:50 -04:00
string GetResourceString ( UiStringKey stringKey ) ;
2013-06-15 16:02:48 -04:00
/// <summary>
/// Returns the value from the preferences corresponding to key
/// </summary>
2013-06-14 00:14:50 -04:00
bool GetBooleanPreference ( PreferenceKey key ) ;
2013-06-15 16:02:48 -04:00
/// <summary>
/// Asks the user the question "messageKey" with the options Yes/No/Cancel, calls the handler corresponding to the answer.
/// </summary>
2013-06-14 00:14:50 -04:00
void AskYesNoCancel ( UiStringKey titleKey , UiStringKey messageKey ,
EventHandler < DialogClickEventArgs > yesHandler ,
EventHandler < DialogClickEventArgs > noHandler ,
EventHandler < DialogClickEventArgs > cancelHandler ,
2013-07-17 10:26:12 -04:00
Context ctx ) ;
/// <summary>
/// Asks the user the question "messageKey" with the options Yes/No/Cancel, but the yes/no strings can be selected freely, calls the handler corresponding to the answer.
/// </summary>
void AskYesNoCancel ( UiStringKey titleKey , UiStringKey messageKey ,
UiStringKey yesString , UiStringKey noString ,
EventHandler < DialogClickEventArgs > yesHandler ,
EventHandler < DialogClickEventArgs > noHandler ,
EventHandler < DialogClickEventArgs > cancelHandler ,
2013-06-14 00:14:50 -04:00
Context ctx ) ;
2013-06-25 15:27:41 -04:00
/// <summary>
/// Returns a Handler object which can run tasks on the UI thread
/// </summary>
Handler UiThreadHandler { get ; }
IProgressDialog CreateProgressDialog ( Context ctx ) ;
2013-07-09 03:59:17 -04:00
IFileStorage GetFileStorage ( IOConnectionInfo iocInfo ) ;
2013-08-01 16:20:39 -04:00
void TriggerReload ( Context context ) ;
2013-12-12 04:24:24 -05:00
/// <summary>
/// Handles a failed certificate validation. Returns true if the users wants to continue, false otherwise.
/// see http://msdn.microsoft.com/en-us/library/system.net.icertificatepolicy(v=vs.110).aspx
/// </summary>
bool OnServerCertificateError ( int certificateProblem ) ;
2013-06-14 00:14:50 -04:00
}
}