Commits

HexRx committed 4239f67

Removed old form

Comments (0)

Files changed (3)

KPDataSave/Forms/KPDataSave.cs

-/*
-    KPDataSave - KeePass plugin which saves database in Dropbox service
-    Copyright (C) 2011 HexRx
-
-    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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Text;
-using System.Windows.Forms;
-using System.Diagnostics;
-using System.Threading;
-
-// KeePass
-using KeePass.Plugins;
-using KeePass.UI;
-
-using DropboxAPI;
-
-namespace KPDataSave.Forms
-{
-    public partial class KPDataSave : Form
-    {
-        private IPluginHost m_host;
-        private DropboxClient client;
-
-        public KPDataSave(IPluginHost host)
-        {
-            this.m_host = host;
-
-            InitializeComponent();
-
-            client = new DropboxClient("hhekhlyshoqxt5s", "h0oh21e8y2seixx");
-
-            // Верхняя картинка
-            BannerFactory.CreateBannerEx(this, picTopImage, Properties.Resources.dropbox_48x48, "KPDataSave", "Options");
-
-            AccountState acc; 
-            try
-            {
-                acc = Config.GetAccountState(m_host);
-            }
-            // Исключение, если в конфигах нет нашей записи или она есть, но пустая
-            catch (NullReferenceException)
-            {
-                // Состояние формы входа
-                SwitchToSignInState();
-                return;
-            }
-            // Состояние формы выхода
-            SwitchToSignOutState();
-        }
-
-        // Вход в акк Dropbox
-        private void btSignIn_Click(object sender, EventArgs e)
-        {
-            // URL куда необходимо перекинуть
-            string url = client.Login_GetUrlLink();
-            // Запуск браузера
-            Process.Start(url);
-            SwitchToAcceptState();
-        }
-
-        // Отмена подтверждения
-        private void btCancel_Click(object sender, System.EventArgs e)
-        {
-            SwitchToSignInState();
-        }
-
-        // Подтверждение
-        private void btAccept_Click(object sender, System.EventArgs e)
-        {
-            try
-            {
-                // Получение токенов
-                client.Login_RequestAccessToken();
-            }
-            catch (DropboxAPI.Exceptions.DropboxClientException)
-            {
-                if (MessageBox.Show("You are not connected app in the web browser!\nRepeat that?", "Accept", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
-                {
-                    btAccept_Click(null, null);
-                }
-                SwitchToSignInState();
-                return;
-            }
-            // Сохраняем токены
-            Config.SaveAccountState(m_host, client.AccessToken.Token, client.AccessToken.TokenSecret);
-            SwitchToSignOutState();
-        }
-
-        // Выход из акка
-        private void btSignOut_Click(object sender, EventArgs e)
-        {
-            // Удаляем токены из конфигов
-            Config.RemoveAccountState(m_host);
-            SwitchToSignInState();
-        }
-        
-        // Переключение состояния формы в AcceptState
-        private void SwitchToAcceptState()
-        {
-            cSignInState.Visible = false;
-            cSignOutState.Visible = false;
-            cAcceptState.Visible = true;
-        }
-
-        // Переключение состояния формы в SignIn
-        private void SwitchToSignInState()
-        {
-            cAcceptState.Visible = false;
-            cSignOutState.Visible = false;
-            cSignInState.Visible = true;
-        }
-
-        // Состояние формы SignOut
-        private void SwitchToSignOutState()
-        {
-            cAcceptState.Visible = false;
-            cSignInState.Visible = false;
-            cSignOutState.Visible = true;
-        }   
-
-    }
-}

KPDataSave/Forms/KPDataSave.designer.cs

-/*
-    KPDataSave - KeePass plugin which saves database in Dropbox service
-    Copyright (C) 2011 HexRx
-
-    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 3 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, see <http://www.gnu.org/licenses/>.
-*/
-
-namespace KPDataSave.Forms
-{
-    partial class KPDataSave
-    {
-        /// <summary>
-        /// Required designer variable.
-        /// </summary>
-        private System.ComponentModel.IContainer components = null;
-
-        /// <summary>
-        /// Clean up any resources being used.
-        /// </summary>
-        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing && (components != null))
-            {
-                components.Dispose();
-            }
-            base.Dispose(disposing);
-        }
-
-        #region Windows Form Designer generated code
-
-        /// <summary>
-        /// Required method for Designer support - do not modify
-        /// the contents of this method with the code editor.
-        /// </summary>
-        private void InitializeComponent()
-        {
-            this.picTopImage = new System.Windows.Forms.PictureBox();
-            this.cSignInState = new System.Windows.Forms.Panel();
-            this.btSignIn = new System.Windows.Forms.Button();
-            this.cAcceptState = new System.Windows.Forms.Panel();
-            this.btCancel = new System.Windows.Forms.Button();
-            this.btAccept = new System.Windows.Forms.Button();
-            this.cSignOutState = new System.Windows.Forms.Panel();
-            this.btSignOut = new System.Windows.Forms.Button();
-            ((System.ComponentModel.ISupportInitialize)(this.picTopImage)).BeginInit();
-            this.cSignInState.SuspendLayout();
-            this.cAcceptState.SuspendLayout();
-            this.cSignOutState.SuspendLayout();
-            this.SuspendLayout();
-            // 
-            // picTopImage
-            // 
-            this.picTopImage.Dock = System.Windows.Forms.DockStyle.Top;
-            this.picTopImage.Location = new System.Drawing.Point(0, 0);
-            this.picTopImage.Name = "picTopImage";
-            this.picTopImage.Size = new System.Drawing.Size(284, 60);
-            this.picTopImage.TabIndex = 0;
-            this.picTopImage.TabStop = false;
-            // 
-            // cSignInState
-            // 
-            this.cSignInState.Controls.Add(this.btSignIn);
-            this.cSignInState.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.cSignInState.Location = new System.Drawing.Point(0, 60);
-            this.cSignInState.Name = "cSignInState";
-            this.cSignInState.Size = new System.Drawing.Size(284, 88);
-            this.cSignInState.TabIndex = 4;
-            // 
-            // btSignIn
-            // 
-            this.btSignIn.Location = new System.Drawing.Point(105, 20);
-            this.btSignIn.Name = "btSignIn";
-            this.btSignIn.Size = new System.Drawing.Size(75, 23);
-            this.btSignIn.TabIndex = 0;
-            this.btSignIn.Text = "Sign In";
-            this.btSignIn.UseVisualStyleBackColor = true;
-            this.btSignIn.Click += new System.EventHandler(this.btSignIn_Click);
-            // 
-            // cAcceptState
-            // 
-            this.cAcceptState.Controls.Add(this.btCancel);
-            this.cAcceptState.Controls.Add(this.btAccept);
-            this.cAcceptState.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.cAcceptState.Location = new System.Drawing.Point(0, 60);
-            this.cAcceptState.Name = "cAcceptState";
-            this.cAcceptState.Size = new System.Drawing.Size(284, 88);
-            this.cAcceptState.TabIndex = 1;
-            this.cAcceptState.Visible = false;
-            // 
-            // btCancel
-            // 
-            this.btCancel.Location = new System.Drawing.Point(105, 49);
-            this.btCancel.Name = "btCancel";
-            this.btCancel.Size = new System.Drawing.Size(75, 23);
-            this.btCancel.TabIndex = 1;
-            this.btCancel.Text = "Cancel";
-            this.btCancel.UseVisualStyleBackColor = true;
-            this.btCancel.Click += new System.EventHandler(this.btCancel_Click);
-            // 
-            // btAccept
-            // 
-            this.btAccept.Location = new System.Drawing.Point(105, 20);
-            this.btAccept.Name = "btAccept";
-            this.btAccept.Size = new System.Drawing.Size(75, 23);
-            this.btAccept.TabIndex = 0;
-            this.btAccept.Text = "Accept";
-            this.btAccept.UseVisualStyleBackColor = true;
-            this.btAccept.Click += new System.EventHandler(this.btAccept_Click);
-            // 
-            // cSignOutState
-            // 
-            this.cSignOutState.Controls.Add(this.btSignOut);
-            this.cSignOutState.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.cSignOutState.Location = new System.Drawing.Point(0, 60);
-            this.cSignOutState.Name = "cSignOutState";
-            this.cSignOutState.Size = new System.Drawing.Size(284, 88);
-            this.cSignOutState.TabIndex = 1;
-            this.cSignOutState.Visible = false;
-            // 
-            // btSignOut
-            // 
-            this.btSignOut.Location = new System.Drawing.Point(105, 20);
-            this.btSignOut.Name = "btSignOut";
-            this.btSignOut.Size = new System.Drawing.Size(75, 23);
-            this.btSignOut.TabIndex = 0;
-            this.btSignOut.Text = "Sign Out";
-            this.btSignOut.UseVisualStyleBackColor = true;
-            this.btSignOut.Click += new System.EventHandler(this.btSignOut_Click);
-            // 
-            // KPDataSave
-            // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(284, 148);
-            this.Controls.Add(this.cSignInState);
-            this.Controls.Add(this.cAcceptState);
-            this.Controls.Add(this.cSignOutState);
-            this.Controls.Add(this.picTopImage);
-            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
-            this.Name = "KPDataSave";
-            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
-            this.Text = "KPDataSave";
-            ((System.ComponentModel.ISupportInitialize)(this.picTopImage)).EndInit();
-            this.cSignInState.ResumeLayout(false);
-            this.cAcceptState.ResumeLayout(false);
-            this.cSignOutState.ResumeLayout(false);
-            this.ResumeLayout(false);
-
-        }
-
-        #endregion
-
-        private System.Windows.Forms.PictureBox picTopImage;
-        private System.Windows.Forms.Panel cSignInState;
-        private System.Windows.Forms.Button btSignIn;
-        private System.Windows.Forms.Panel cAcceptState;
-        private System.Windows.Forms.Button btCancel;
-        private System.Windows.Forms.Button btAccept;
-        private System.Windows.Forms.Panel cSignOutState;
-        private System.Windows.Forms.Button btSignOut;
-    }
-}

KPDataSave/Forms/KPDataSave.resx

-<?xml version="1.0" encoding="utf-8"?>
-<root>
-  <!-- 
-    Microsoft ResX Schema 
-    
-    Version 2.0
-    
-    The primary goals of this format is to allow a simple XML format 
-    that is mostly human readable. The generation and parsing of the 
-    various data types are done through the TypeConverter classes 
-    associated with the data types.
-    
-    Example:
-    
-    ... ado.net/XML headers & schema ...
-    <resheader name="resmimetype">text/microsoft-resx</resheader>
-    <resheader name="version">2.0</resheader>
-    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
-    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
-    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
-    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
-    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
-        <value>[base64 mime encoded serialized .NET Framework object]</value>
-    </data>
-    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
-        <comment>This is a comment</comment>
-    </data>
-                
-    There are any number of "resheader" rows that contain simple 
-    name/value pairs.
-    
-    Each data row contains a name, and value. The row also contains a 
-    type or mimetype. Type corresponds to a .NET class that support 
-    text/value conversion through the TypeConverter architecture. 
-    Classes that don't support this are serialized and stored with the 
-    mimetype set.
-    
-    The mimetype is used for serialized objects, and tells the 
-    ResXResourceReader how to depersist the object. This is currently not 
-    extensible. For a given mimetype the value must be set accordingly:
-    
-    Note - application/x-microsoft.net.object.binary.base64 is the format 
-    that the ResXResourceWriter will generate, however the reader can 
-    read any of the formats listed below.
-    
-    mimetype: application/x-microsoft.net.object.binary.base64
-    value   : The object must be serialized with 
-            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
-            : and then encoded with base64 encoding.
-    
-    mimetype: application/x-microsoft.net.object.soap.base64
-    value   : The object must be serialized with 
-            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
-            : and then encoded with base64 encoding.
-
-    mimetype: application/x-microsoft.net.object.bytearray.base64
-    value   : The object must be serialized into a byte array 
-            : using a System.ComponentModel.TypeConverter
-            : and then encoded with base64 encoding.
-    -->
-  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
-    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
-    <xsd:element name="root" msdata:IsDataSet="true">
-      <xsd:complexType>
-        <xsd:choice maxOccurs="unbounded">
-          <xsd:element name="metadata">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" />
-              </xsd:sequence>
-              <xsd:attribute name="name" use="required" type="xsd:string" />
-              <xsd:attribute name="type" type="xsd:string" />
-              <xsd:attribute name="mimetype" type="xsd:string" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="assembly">
-            <xsd:complexType>
-              <xsd:attribute name="alias" type="xsd:string" />
-              <xsd:attribute name="name" type="xsd:string" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="data">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
-              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
-              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="resheader">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" />
-            </xsd:complexType>
-          </xsd:element>
-        </xsd:choice>
-      </xsd:complexType>
-    </xsd:element>
-  </xsd:schema>
-  <resheader name="resmimetype">
-    <value>text/microsoft-resx</value>
-  </resheader>
-  <resheader name="version">
-    <value>2.0</value>
-  </resheader>
-  <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-  <resheader name="writer">
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-</root>