/// <summary>
 /// Event handler to implement auto sync on open
 /// </summary>
 private void OnFileOpened(object sender, FileOpenedEventArgs e)
 {
     if (AutoSyncMode.OPEN == (m_autoSync & AutoSyncMode.OPEN))
     {
         if (Keys.Shift == (Control.ModifierKeys & Keys.Shift))
         {
             ShowMessage("Shift Key pressed. Auto Sync ignored.", true);
         }
         else if (!LoadConfiguration())
         {
             ShowMessage("No valid configuration found. Auto Sync ignored.", true);
         }
         else
         {
             syncWithGoogle(SyncCommand.SYNC, true);
         }
     }
 }
예제 #2
0
        private static void OTPDAO_FileOpened(object sender, FileOpenedEventArgs e)
        {
            List <string> lMsg     = new List <string>();
            bool          bUseDB   = Config.UseDBForOTPSeeds(e.Database);
            bool          bPreload = Config.PreloadOTPDB(e.Database);

            if (bUseDB)
            {
                //OTP-DB has to be used
                //Now check for KeePassOTB.DB entry that needs to be migrated

                //If CustomData exists => No need to check any further
                CheckAndMigrate(e.Database, OTP_Migrations.Entry2CustomData);
                lMsg.Add("Uses OTP database: true");
                lMsg.Add("Preload OTP database: " + bPreload.ToString());
                OTPHandler_DB h = GetOTPHandler(e.Database);
                if (h == null)
                {
                    lMsg.Add("Error getting OTP-DB: Handler: true");
                    RemoveHandler(e.Database.IOConnectionInfo.Path, true);
                }
                h = GetOTPHandler(e.Database);
                if (h != null)
                {
                    h.RememberInitialOTPDB(e.Database);
                    h.SetDB(e.Database, bPreload);
                }
                else
                {
                    lMsg.Add("Error restoring OTP-DB: Handler: true");
                }
            }
            else
            {
                CheckAndMigrate(e.Database);
                bool bRemoved = RemoveHandler(e.Database.IOConnectionInfo.Path, true);
                lMsg.Add("Uses OTP database: " + bUseDB.ToString());
                lMsg.Add("Preload OTP database: " + bPreload.ToString());
                lMsg.Add("Removed OTP database from buffer:" + bRemoved.ToString());
            }
            PluginDebug.AddInfo("Database file opened", 0, lMsg.ToArray());
        }
예제 #3
0
        /// <summary>
        /// Triggered when a KeePass database is being opened
        /// </summary>
        private async void OnKeePassDatabaseOpened(object sender, FileOpenedEventArgs fileOpenedEventArgs)
        {
            var databasePath = fileOpenedEventArgs.Database.IOConnectionInfo.Path;

            // If the database is located under the folder from where KeePass runs, use a relative path instead of the absolute path
            if (fileOpenedEventArgs.Database.IOConnectionInfo.Path.StartsWith(AppDomain.CurrentDomain.BaseDirectory))
            {
                databasePath = databasePath.Remove(0, AppDomain.CurrentDomain.BaseDirectory.Length);
            }

            // Add the KeePass database instance to the already available configuration
            var config = Configuration.GetPasswordDatabaseConfiguration(databasePath);

            config.KeePassDatabase = fileOpenedEventArgs.Database;

            // Check if we should sync this database
            if (config.DoNotSync || !fileOpenedEventArgs.Database.IOConnectionInfo.IsLocalFile())
            {
                return;
            }
            if (!_fileOfflineMenuItem.Checked)
            {
                Host.MainWindow.SetStatusEx(string.Format("OneDriveSync has been set to offline, skipping sync for database {0}", fileOpenedEventArgs.Database.Name));
                return;
            }

            // Check if the database configuration of the opened KeePass database is set to retrieve the OneDrive Refresh Token from the KeePass database itself
            if (config.RefreshTokenStorage == OneDriveRefreshTokenStorage.KeePassDatabase && string.IsNullOrEmpty(config.RefreshToken))
            {
                // Retrieve the OneDrive Refresh Token from the KeePass database that is being opened
                config.RefreshToken = Utilities.GetRefreshTokenFromKeePassDatabase(fileOpenedEventArgs.Database);
            }

            await KeePassDatabase.SyncDatabase(databasePath, KeePassDatabase.UpdateStatus, false, config);

            // If the OneDrive Refresh Token is stored in the KeePass database, we must trigger a save of the database here so to ensure that the actual value gets saved into the KDBX
            if (config.RefreshTokenStorage == OneDriveRefreshTokenStorage.KeePassDatabase)
            {
                fileOpenedEventArgs.Database.Save(null);
            }
        }
예제 #4
0
        /// <summary>
        /// Event handler to implement auto sync on open
        /// </summary>
        private void OnFileOpened(object sender, FileOpenedEventArgs e)
        {
            var conf = new SafeVaultConf(_host.Database);

            if (AutoSyncMode.Open != (conf.AutoSyncMode & AutoSyncMode.Open))
            {
                return;
            }

            if (Keys.Shift == (Control.ModifierKeys & Keys.Shift))
            {
                SetStatusText("Shift Key pressed. Auto Sync ignored.");
                return;
            }
            if (!IsSyncConfigured(conf))
            {
                SetStatusText("SafeVault sync not configured.");
                return;
            }
            SyncWithSafeVault(SyncCommand.SyncLocal);
        }
예제 #5
0
        /// <summary>
        /// EventListener Method, called if user opens database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnFileOpened(object sender, FileOpenedEventArgs e)
        {
            string fName = "";

            if (e.Database.IOConnectionInfo.IsLocalFile())
            {
                // local file
                var f = new FileInfo(e.Database.IOConnectionInfo.Path);
                filePath = f.FullName;
                fName    = f.Name;

                fileModified = f.LastWriteTime.Year + "-" + f.LastWriteTime.Month.ToString("00") + "-" + f.LastWriteTime.Day.ToString("00") + "_" + f.LastWriteTime.Hour.ToString("00") + "-" + f.LastWriteTime.Minute.ToString("00") + "-" + f.LastWriteTime.Second.ToString("00");

                // remove file extension
                if (!string.IsNullOrEmpty(f.Extension))
                {
                    fileName = fName.Substring(0, fName.Length - f.Extension.Length);
                }

                f = null;
            }
        }
        private void CheckPluginKeyState(object sender, FileOpenedEventArgs e)
        {
            var rootEntries = e.Database.RootGroup.GetEntries(false);

            foreach (var entry in rootEntries)
            {
                if (entry.Strings.ReadSafe(PwDefs.TitleField).Equals(SAVED_KEY_NAME, StringComparison.OrdinalIgnoreCase))
                {
                    CryptoKey = Convert.FromBase64String(entry.Strings.ReadSafe(PwDefs.PasswordField));
                    return;
                }
            }
            var newEntry = new PwEntry(true, true);
            var key      = CryptoHelper.CreateAESKey();

            newEntry.Strings.Set(PwDefs.TitleField, new ProtectedString(false, SAVED_KEY_NAME));
            newEntry.Strings.Set(PwDefs.PasswordField, new ProtectedString(true, key));
            e.Database.RootGroup.AddEntry(newEntry, true, true);

            CryptoKey = Convert.FromBase64String(key);

            _pHost.MainWindow.UpdateUI(false, null, false, null, true, e.Database.RootGroup, true);
        }
예제 #7
0
        /// <summary>
        /// Triggered when a KeePass database is being opened
        /// </summary>
        private async static void OnKeePassDatabaseOpened(object sender, FileOpenedEventArgs fileOpenedEventArgs)
        {
            var databasePath = fileOpenedEventArgs.Database.IOConnectionInfo.Path;

            // If the database is located under the folder from where KeePass runs, use a relative path instead of the absolute path
            if (fileOpenedEventArgs.Database.IOConnectionInfo.Path.StartsWith(Environment.CurrentDirectory))
            {
                databasePath = databasePath.Remove(0, Environment.CurrentDirectory.Length + 1);
            }

            // Add the KeePass database instance to the already available configuration
            var config = Configuration.GetPasswordDatabaseConfiguration(databasePath);

            config.KeePassDatabase = fileOpenedEventArgs.Database;

            // Check if we should sync this database
            if (config.DoNotSync || !fileOpenedEventArgs.Database.IOConnectionInfo.IsLocalFile())
            {
                return;
            }

            // Check if the database configuration of the opened KeePass database is set to retrieve the OneDrive Refresh Token from the KeePass database itself
            if (config.RefreshTokenStorage == OneDriveRefreshTokenStorage.KeePassDatabase)
            {
                // Retrieve the OneDrive Refresh Token from the KeePass database that is being opened
                config.RefreshToken = Utilities.GetRefreshTokenFromKeePassDatabase(fileOpenedEventArgs.Database);
            }

            await KeePassDatabase.SyncDatabase(fileOpenedEventArgs.Database.IOConnectionInfo.Path, KeePassDatabase.UpdateStatus, false, config);

            // If the OneDrive Refresh Token is stored in the KeePass database, we must trigger a save of the database here so to ensure that the actual value gets saved into the KDBX
            if (config.RefreshTokenStorage == OneDriveRefreshTokenStorage.KeePassDatabase)
            {
                fileOpenedEventArgs.Database.Save(null);
            }
        }
예제 #8
0
 private void Storage_FileOpened1(object sender, FileOpenedEventArgs e)
 {
     view.SetFilePath(e.FilePath);
     view.SetTasks(storage.GetTasks());
 }
예제 #9
0
 private void OnOpenFile(object sender, FileOpenedEventArgs e)
 {
     OpenComputerEditor(e.SourcePath, e.TempPath);
 }
예제 #10
0
 /// <summary>
 /// Checks if the event should be raised for the given arguments. Default implementation
 /// checks if the <see cref="FileOpenedEventArgs.OpenedPath"/> is contained in <see cref="Path"/>.
 /// </summary>
 /// <param name="args">Arguments for the event.</param>
 /// <returns>True if the event should be raised, false to ignore it.</returns>
 protected virtual bool ShouldRaiseEventImpl(FileOpenedEventArgs args)
 {
     return(args.OpenedPath.IsInDirectory(Path, true));
 }
예제 #11
0
 private void SourceFileSystemWatcher_Opened(object sender, FileOpenedEventArgs e)
 {
     _openedFiles.Add(e.OpenedPath);
 }
예제 #12
0
 private void OnKPDBOpen(object sender, FileOpenedEventArgs e)
 {
     EnsureDBIconIsInKPRPCIconCache();
     //KeePassRPCService.ensureDBisOpenEWH.Set(); // signal that DB is now open so any waiting JSONRPC thread can go ahead
     SignalAllManagedRPCClients(KeePassRPC.DataExchangeModel.Signal.DATABASE_OPEN);
 }
예제 #13
0
 private bool ShouldRaiseEvent(FileOpenedEventArgs args)
 {
     return(ShouldRaiseEventImpl(args));
 }
예제 #14
0
 protected virtual void OnFileOpenedEvent(FileOpenedEventArgs e)
 {
     if (FileOpenedEvent != null)
     {
         FileOpenedEvent(this, e);
     }
 }
예제 #15
0
 async void OnOpenDatabase(object sender, FileOpenedEventArgs e)
 {
     await Task.Run(() => Syncronize(e.Database));
 }
 /// <summary>
 /// Called when file is opened so we can check vault entries in it.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The event args</param>
 private void OnFileOpened(object sender, FileOpenedEventArgs e)
 {
     this.DoTheStuffAsync();
 }
예제 #17
0
 public void OpenFile(bool saveDsd = true)
 {
     Layer.IsLoading = true;
     ThreadPool.QueueUserWorkItem(delegate
     {
         Exception openFileException = OpenFileSync(saveDsd);
         FileOpenedEventArgs args = new FileOpenedEventArgs { OpenerService = this, Exception = openFileException };
         OnFileOpenedEvent(args); // SdJ added
     });
 }
예제 #18
0
        /// <summary>
        /// Raise the <see cref="IFileSystemWatcher.Opened"/> event on watchers.
        /// </summary>
        /// <param name="path">Absolute path to the opened file.</param>
        public void RaiseOpened(UPath path)
        {
            var args = new FileOpenedEventArgs(path);

            Dispatch(args, (w, a) => w.RaiseOpened(a));
        }
예제 #19
0
        private void TEXTool_FileOpened(object sender, FileOpenedEventArgs e)
        {
            this.Text = String.Format("Klei Studio - TEXTool - [{0}]", e.FileName);
            this.formatToolStripStatusLabel.Text = String.Format("Format: {0}", e.Format);
            this.sizeToolStripStatusLabel.Text = String.Format("Size: {0}", e.Size);
            this.mipmapsToolStripStatusLabel.Text = String.Format("Mipmaps: {0}", e.Mipmaps);
            this.platformToolStripStatusLabel.Text = String.Format("Platform: {0}", e.Platform);
            this.textureTypeToolStripStatusLabel.Text = String.Format("Texture Type: {0}", e.TexType);

            if (e.PreCave)
                MessageBox.Show(@"Error, this is a pre 'Cave Update' TEX file. If you want to convert this, please use an older version of TEXTool or 'update' the file using the converter found in the offical thread.");
        }
 private void OnFileOpened(object sender, FileOpenedEventArgs e)
 {
     throw new NotImplementedException();
 }
예제 #21
0
        private void OnDatabaseOpened(object sender, FileOpenedEventArgs args)
        {
            var path = args.Database.IOConnectionInfo.Path;

            CertificateCache.SetCachedItemAsValid(path);
        }
예제 #22
0
 private void FileOpened(object sender, FileOpenedEventArgs e)
 {
     PropertyChanged(nameof(Title));
 }