-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a637ed9
commit 5e8d5ec
Showing
13 changed files
with
700 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.vs | ||
/KPSimpleBackup/bin | ||
/KPSimpleBackup/obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28307.489 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KPSimpleBackup", "KPSimpleBackup\KPSimpleBackup.csproj", "{90AE5E95-FAC2-46D6-8B6B-BAB535323BB1}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{90AE5E95-FAC2-46D6-8B6B-BAB535323BB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{90AE5E95-FAC2-46D6-8B6B-BAB535323BB1}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{90AE5E95-FAC2-46D6-8B6B-BAB535323BB1}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{90AE5E95-FAC2-46D6-8B6B-BAB535323BB1}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {B99C9C95-947A-4F53-9A66-BC0C4C747404} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
using System; | ||
using System.Windows.Forms; | ||
using KeePass.Forms; | ||
using KeePass.Plugins; | ||
using KeePassLib; | ||
using KeePassLib.Serialization; | ||
|
||
namespace KPSimpleBackup | ||
{ | ||
public sealed class KPSimpleBackupExt : Plugin | ||
{ | ||
private IPluginHost m_host = null; | ||
private KPSimpleBackupConfig m_config = null; | ||
|
||
public override bool Initialize(IPluginHost host) | ||
{ | ||
if (host == null) return false; | ||
|
||
m_host = host; | ||
m_config = new KPSimpleBackupConfig(m_host.CustomConfig); | ||
|
||
// add backup action event handler | ||
m_host.MainWindow.FileSaved += this.OnSaveAction; | ||
|
||
// initialization successful | ||
return true; | ||
} | ||
|
||
public override void Terminate() | ||
{ | ||
// Remove event handler | ||
m_host.MainWindow.FileSaved -= this.OnSaveAction; | ||
} | ||
|
||
public override string UpdateUrl | ||
{ | ||
get | ||
{ | ||
return "https://www.weberone.de/kpsimplebackup.version"; | ||
} | ||
} | ||
|
||
public override ToolStripMenuItem GetMenuItem(PluginMenuType t) | ||
{ | ||
// Provide a menu item for the main location(s) | ||
if (t == PluginMenuType.Main) | ||
{ | ||
ToolStripMenuItem tsmi = new ToolStripMenuItem(); | ||
|
||
tsmi.Text = "KPSimpleBackup"; | ||
//tsmi.Click += this.OnOptionsClicked; | ||
|
||
ToolStripMenuItem backupNowItem = new ToolStripMenuItem(); | ||
backupNowItem.Text = "Backup Database now!"; | ||
backupNowItem.Click += this.OnMenuBackupNow; | ||
|
||
ToolStripMenuItem openSettings = new ToolStripMenuItem(); | ||
openSettings.Text = "Settings"; | ||
openSettings.Click += this.OnMenuSettings; | ||
|
||
|
||
tsmi.DropDownItems.Add(backupNowItem); | ||
tsmi.DropDownItems.Add(openSettings); | ||
|
||
return tsmi; | ||
} | ||
|
||
return null; // No menu items in other locations | ||
} | ||
|
||
private void OnMenuSettings(object sender, EventArgs e) | ||
{ | ||
SettingsForm settingsWindow = new SettingsForm(this.m_config); | ||
settingsWindow.ShowDialog(); | ||
settingsWindow.Dispose(); | ||
settingsWindow = null; | ||
} | ||
|
||
private void OnSaveAction(object sender, FileSavedEventArgs e) | ||
{ | ||
this.BackupAction(e.Database); | ||
} | ||
|
||
private void BackupAction(PwDatabase database) | ||
{ | ||
string dbName = database.Name; | ||
string time = DateTime.Now.ToString(@"yyyy\.MM\.dd\_H\.mm\.ss"); | ||
string backupFolderPath = this.m_config.BackupPath; | ||
string path = backupFolderPath + dbName + "_" + time + ".kdbx"; | ||
IOConnectionInfo connection = IOConnectionInfo.FromPath(path); | ||
|
||
// save database TODO add Logger | ||
database.SaveAs(connection, false, null); | ||
} | ||
|
||
private void OnMenuBackupNow(object sender, EventArgs e) | ||
{ | ||
this.BackupAction(m_host.Database); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{90AE5E95-FAC2-46D6-8B6B-BAB535323BB1}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>KPSimpleBackup</RootNamespace> | ||
<AssemblyName>KPSimpleBackup</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="KeePass"> | ||
<HintPath>D:\Downloads\KeePass-2.41\KeePass.exe</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="KPSimpleBackup.cs" /> | ||
<Compile Include="KPSimpleBackupConfig.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Properties\Settings.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DesignTimeSharedInput>True</DesignTimeSharedInput> | ||
<DependentUpon>Settings.settings</DependentUpon> | ||
</Compile> | ||
<Compile Include="SettingsForm.cs"> | ||
<SubType>Form</SubType> | ||
</Compile> | ||
<Compile Include="SettingsForm.Designer.cs"> | ||
<DependentUpon>SettingsForm.cs</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.config" /> | ||
<None Include="Properties\Settings.settings"> | ||
<Generator>SettingsSingleFileGenerator</Generator> | ||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="SettingsForm.resx"> | ||
<DependentUpon>SettingsForm.cs</DependentUpon> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using KeePass.App.Configuration; | ||
|
||
namespace KPSimpleBackup | ||
{ | ||
public class KPSimpleBackupConfig | ||
{ | ||
private AceCustomConfig customConfig; | ||
|
||
public KPSimpleBackupConfig(AceCustomConfig customConfig) | ||
{ | ||
this.customConfig = customConfig; | ||
} | ||
|
||
public bool BackupConfigured | ||
{ | ||
get | ||
{ | ||
return this.customConfig.GetBool("KPSimpleBackupConfig_backupConfigured", false); | ||
} | ||
|
||
set | ||
{ | ||
this.customConfig.SetBool("KPSimpleBackupConfig_backupConfigured", value); | ||
} | ||
} | ||
|
||
public String BackupPath | ||
{ | ||
get | ||
{ | ||
return this.customConfig.GetString("KPSimpleBackupConfig_backupPath"); | ||
} | ||
|
||
set | ||
{ | ||
this.customConfig.SetString("KPSimpleBackupConfig_backupPath", value); | ||
} | ||
} | ||
|
||
public String BackupName | ||
{ | ||
get | ||
{ | ||
return this.customConfig.GetString("KPSimpleBackupConfig_backupName", ""); | ||
} | ||
|
||
set | ||
{ | ||
this.customConfig.SetString("KPSimpleBackupConfig_backupName", value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Resources; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// Allgemeine Informationen über eine Assembly werden über die folgenden | ||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, | ||
// die einer Assembly zugeordnet sind. | ||
[assembly: AssemblyTitle("KPSimpleBackup")] | ||
[assembly: AssemblyDescription("Simple Plugin for KeePass-Backups (also working together with IOProtocol Plugin)")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Marvin Weber (weberone)")] | ||
[assembly: AssemblyProduct("KeePass Plugin")] | ||
[assembly: AssemblyCopyright("Copyright © 2019")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly | ||
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von | ||
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. | ||
[assembly: ComVisible(false)] | ||
|
||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird | ||
[assembly: Guid("90ae5e95-fac2-46d6-8b6b-bab535323bb1")] | ||
|
||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: | ||
// | ||
// Hauptversion | ||
// Nebenversion | ||
// Buildnummer | ||
// Revision | ||
// | ||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, | ||
// indem Sie "*" wie unten gezeigt eingeben: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("0.1.0.0")] | ||
[assembly: AssemblyFileVersion("0.1.0.0")] | ||
[assembly: NeutralResourcesLanguage("en")] | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> | ||
<Profiles> | ||
<Profile Name="(Default)" /> | ||
</Profiles> | ||
</SettingsFile> |
Oops, something went wrong.