/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2013 Dominik Reichl This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ using System; using System.Collections.Generic; using System.IO; using System.Drawing; using KeePassLib; using KeePassLib.Interfaces; namespace KeePass.DataExchange { public abstract class FileFormatProvider { public abstract bool SupportsImport { get; } public abstract bool SupportsExport { get; } public abstract string FormatName { get; } public virtual string DisplayName { get { return this.FormatName; } } /// /// Default file name extension, without leading dot. /// If there are multiple default/equivalent extensions /// (like e.g. "html" and "htm"), specify all of them /// separated by a '|' (e.g. "html|htm"). /// public virtual string DefaultExtension { get { return string.Empty; } } public virtual bool RequiresFile { get { return true; } } public virtual bool SupportsUuids { get { return false; } } public virtual bool RequiresKey { get { return false; } } /// /// This property specifies if entries are only appended to the /// end of the root group. This is true for example if the /// file format doesn't support groups (i.e. no hierarchy). /// public virtual bool ImportAppendsToRootGroupOnly { get { return false; } } /// /// Called before the Export method is invoked. /// /// Returns true, if the Export method /// can be invoked. If it returns false, something has /// failed and the export process should be aborted. public virtual bool TryBeginExport() { return true; } /// /// Import a stream into a database. Throws an exception if an error /// occurs. Do not call the base class method when overriding it. /// /// Data storage into which the data will be imported. /// Input stream to read the data from. /// Status logger. May be null. public abstract void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger); /// /// Export data into a stream. Throws an exception if an error /// occurs (like writing to stream fails, etc.). Returns true, /// if the export was successful. /// /// Contains the data source and detailed /// information about which entries should be exported. /// Output stream to write the data to. /// Status logger. May be null. /// Returns false, if the user has aborted the export /// process (like clicking Cancel in an additional export settings /// dialog). public virtual bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger) { throw new NotSupportedException(); } } }