コード例 #1
0
ファイル: EntryEx.cs プロジェクト: nthobois/7Pass
        public EntryEx(Entry entry)
        {
            if (entry == null)
                throw new ArgumentNullException("entry");

            _entry = entry;
        }
コード例 #2
0
ファイル: WebView.xaml.cs プロジェクト: nthobois/7Pass
        protected override void OnNavigatedTo(
            bool cancelled, NavigationEventArgs e)
        {
            if (cancelled || _entry != null)
                return;

            var database = Cache.Database;
            if (database == null)
            {
                GoBack<MainPage>();
                return;
            }

            var id = NavigationContext
                .QueryString["entry"];

            _entry = database.GetEntry(id) ??
                CurrentEntry.Entry;

            foreach (var field in _entry.CustomFields.Take(3))
            {
                var item = new ApplicationBarMenuItem(field.Key);
                item.Click += (s, _) => SetValue(field.Value);
                ApplicationBar.MenuItems.Add(item);
            }
        }
コード例 #3
0
ファイル: MoveTarget.xaml.cs プロジェクト: oldlaurel/WinPass
        protected override void OnNavigatedTo(
            bool cancelled, NavigationEventArgs e)
        {
            if (cancelled)
                return;

            _database = Cache.Database;
            if (_database == null)
            {
                this.BackToDBs();
                return;
            }

            string id;
            var queries = NavigationContext.QueryString;

            if (queries.TryGetValue("entry", out id))
                _entry = _database.GetEntry(id);
            else
            {
                id = queries["group"];
                _group = _database.GetGroup(id);
            }

            _target = _database.Root;
            Refresh();
        }
コード例 #4
0
ファイル: EntryBinding.cs プロジェクト: AFPass/7Pass
        public EntryBinding(Entry entry)
        {
            if (entry == null)
                throw new ArgumentNullException("entry");

            _entry = entry;
            _addedFields = new List<Field>();
        }
コード例 #5
0
ファイル: XmlWriter.cs プロジェクト: oldlaurel/WinPass
        /// <summary>
        /// Deletes the specified entry.
        /// </summary>
        /// <param name="entry">The entry.</param>
        public void Delete(Entry entry)
        {
            if (entry == null)
                throw new ArgumentNullException("entry");

            var time = GetTime(DateTime.Now);
            var element = _entries[entry.ID];

            element.Remove();
            _entries.Remove(entry.ID);

            _deletedObjs.Add(new XElement("DeletedObject",
                new XElement("UUID", entry.ID),
                new XElement("DeletionTime", time)));
        }
コード例 #6
0
ファイル: GroupItem.cs プロジェクト: MiffyLiye/codesafe
        public GroupItem(Entry entry, Dispatcher dispatcher)
        {
            if (entry == null) throw new ArgumentNullException("entry");
            if (dispatcher == null) throw new ArgumentNullException("dispatcher");

            Title = entry.Title;
            Notes = entry.UserName;
            Icon = ThemeData.GetImage("entry");

            Overlay = Cache.GetOverlay(
                dispatcher, entry.Icon);

            _data = entry;
            _targetUri = Navigation.GetPathTo
                <EntryDetails>("id={0}", entry.ID);
        }
コード例 #7
0
ファイル: PassGen.xaml.cs プロジェクト: nthobois/7Pass
        protected override void OnNavigatedTo(
            bool cancelled, NavigationEventArgs e)
        {
            if (cancelled)
                return;

            var database = Cache.Database;
            if (database == null)
            {
                GoBack<MainPage>();
                return;
            }

            var id = NavigationContext
                .QueryString["id"];

            _entry = database.GetEntry(id)
                ?? CurrentEntry.Entry;

            LoadCurrentState();
        }
コード例 #8
0
ファイル: XmlParser.cs プロジェクト: gkardava/WinPass
        private Entry ParseEntry(XmlReader reader)
        {
            var id = ReadId(reader);
            var icon = ParseIcon(reader);
            var lastModified = ReadLastModified(reader);
            var fields = ReadFields(reader);

            // Needed to ensure protected
            // fields decryption
            ReadHistories(reader);

            if (fields.Count == 0)
                return null;

            var entry = new Entry(fields)
            {
                ID = id,
                Icon = icon,
                LastModified = lastModified,
            };

            return entry;
        }
コード例 #9
0
ファイル: EntryDetails.xaml.cs プロジェクト: nthobois/7Pass
        protected override void OnNavigatedTo(
            bool cancelled, NavigationEventArgs e)
        {
            if (cancelled)
                return;

            if (_entry != null)
            {
                UpdateNotes();
                txtPassword.Text = _entry.Password;

                _binding.HasChanges =
                    CurrentEntry.HasChanges;

                return;
            }

            var database = Cache.Database;
            if (database == null)
            {
                GoBack<MainPage>();
                return;
            }

            string id;
            var queries = NavigationContext.QueryString;

            Entry entry;
            if (queries.TryGetValue("id", out id))
            {
                entry = database.GetEntry(id);

                ThreadPool.QueueUserWorkItem(
                    _ => Cache.AddRecent(id));
            }
            else
            {
                entry = new Entry
                {
                    Password = Generator
                        .CharacterSets.NewEntry(),
                };
            }

            DisplayEntry(entry);
        }
コード例 #10
0
ファイル: EntryDetails.xaml.cs プロジェクト: nthobois/7Pass
        private void DisplayEntry(Entry entry)
        {
            _entry = entry;

            _binding = new EntryEx(entry);
            _binding.HasChangesChanged += _binding_HasChangesChanged;
            _binding.HasChanges = entry.IsNew();

            CurrentEntry.Entry = entry;
            CurrentEntry.HasChanges = entry.IsNew();

            UpdateNotes();
            DataContext = _binding;

            var fields = entry.CustomFields.Count;
            if (fields == 0)
            {
                lnkFields.Visibility =
                    Visibility.Collapsed;
            }
            else
            {
                lnkFields.Visibility =
                    Visibility.Visible;

                lnkFields.Content = string.Format(
                    Properties.Resources.FieldsLink,
                    fields);
            }
        }
コード例 #11
0
ファイル: Search.xaml.cs プロジェクト: MiffyLiye/codesafe
 private static bool Matches(
     Entry entry, string text)
 {
     return Matches(text, new[]
     {
         entry.Title,
         entry.UserName,
         entry.Notes,
     });
 }
コード例 #12
0
ファイル: XmlWriter.cs プロジェクト: oldlaurel/WinPass
        /// <summary>
        /// Updates the details of the specified entry.
        /// </summary>
        /// <param name="entry">The entry.</param>
        public void Details(Entry entry)
        {
            if (entry == null)
                throw new ArgumentNullException("entry");

            var element = _entries[entry.ID];

            element
                .Element("History")
                .Add(Clone(element));

            SetFields(element, entry.GetAllFields());

            var time = DateTime.Now;
            entry.LastModified = time;

            element
                .Element("Times")
                .Element("LastModificationTime")
                .Value = GetTime(time);
        }
コード例 #13
0
ファイル: EntryDetails.xaml.cs プロジェクト: AFPass/7Pass
 private void UpdateFieldsCount(Entry entry)
 {
     var mnuFields = AppMenu(0);
     mnuFields.Text = string.Format(
         Properties.Resources.FieldsMenuItem,
         entry.CustomFields.Count);
 }
コード例 #14
0
ファイル: XmlWriter.cs プロジェクト: oldlaurel/WinPass
        /// <summary>
        /// Saves the new entry.
        /// </summary>
        /// <param name="entry">The entry.</param>
        public void New(Entry entry)
        {
            if (entry == null)
                throw new ArgumentNullException("entry");

            var time = DateTime.Now;
            entry.LastModified = time;

            var timeValue = GetTime(time);
            var element = new XElement("Entry",
                new XElement("UUID", entry.ID),
                new XElement("IconID", 0),
                new XElement("ForegroundColor"),
                new XElement("BackgroundColor"),
                new XElement("OverrideURL"),
                new XElement("Tags"),
                new XElement("Times",
                    new XElement("LastModificationTime", timeValue),
                    new XElement("CreationTime", timeValue),
                    new XElement("LastAccessTime", timeValue),
                    new XElement("ExpiryTime", timeValue),
                    new XElement("Expires", "False"),
                    new XElement("UsageCount", 0),
                    new XElement("LocationChanged", timeValue)));

           

            element.Add(
                new XElement("AutoType",
                    new XElement("Enabled", "True"),
                    new XElement("DataTransferObfuscation", 0),
                    new XElement("Association",
                        new XElement("Window", "Target Window"),
                        new XElement("KeystrokeSequence",
                            "{USERNAME}{TAB}{PASSWORD}{TAB}{ENTER}"))),
                new XElement("History"));

            SetFields(element, entry.GetAllFields());

            var group = _groups[entry.Group.ID];
            group.Add(element);

            group
                .Element("Times")
                .Element("LastModificationTime")
                .Value = timeValue;

            _entries.Add(entry.ID, element);
        }
コード例 #15
0
ファイル: EntryDetails.xaml.cs プロジェクト: AFPass/7Pass
        protected override void OnNavigatedTo(
            bool cancelled, NavigationEventArgs e)
        {
            if (cancelled)
                return;

            if (_binding != null)
            {
                _binding.Save();

                UpdateNotes();
                UpdateFieldsCount(_entry);
                txtPassword.Text = _binding.Password;

                return;
            }

            var database = Cache.Database;
            if (database == null)
            {
                this.BackToDBs();
                return;
            }

            string id;
            var queries = NavigationContext.QueryString;

            Entry entry;
            if (queries.TryGetValue("id", out id))
            {
                entry = database.GetEntry(id);

                ThreadPool.QueueUserWorkItem(
                    _ => Cache.AddRecent(id));
            }
            else
            {
                var config = database.Configuration;

                entry = new Entry
                {
                    Password = Generator
                        .CharacterSets.NewEntry(),
                    UserName = config.DefaultUserName,
                    Protections =
                        {
                            Title = config.ProtectTitle,
                            UserName = config.ProtectUserName,
                            Password = config.ProtectPassword,
                        }
                };

                txtTitle.Loaded += (sender, e1) =>
                    txtTitle.Focus();
            }

            DisplayEntry(entry);
            UpdateFieldsCount(entry);
        }
コード例 #16
0
ファイル: DatabaseWriter.cs プロジェクト: AFPass/7Pass
 /// <summary>
 /// Deletes the specified entry.
 /// </summary>
 /// <param name="entry">The entry.</param>
 public void Delete(Entry entry)
 {
     _xmlWriter.Delete(entry);
 }
コード例 #17
0
ファイル: DatabaseWriter.cs プロジェクト: AFPass/7Pass
 /// <summary>
 /// Updates the location of the specified entry.
 /// </summary>
 /// <param name="entry">The entry.</param>
 public void Location(Entry entry)
 {
     _xmlWriter.Location(entry);
 }
コード例 #18
0
ファイル: GroupDetails.xaml.cs プロジェクト: AFPass/8Pass
        private void Delete(Entry entry)
        {
            var database = Cache.Database;
            var pernament = IsPernamentDelete();

            if (!ConfirmDelete(pernament,
                Properties.Resources.Entry,
                entry.Title))
            {
                return;
            }

            if (!pernament)
            {
                MoveToRecycleBin((writer, recycleBin) =>
                {
                    entry.Group.Entries
                        .Remove(entry);
                    recycleBin.Add(entry);

                    writer.Location(entry);
                });
            }
            else
            {
                Save(x =>
                {
                    x.Delete(entry);
                    database.Remove(entry);
                });
            }
        }
コード例 #19
0
ファイル: EntryDetails.xaml.cs プロジェクト: gkardava/WinPass
        private void DisplayEntry(Entry entry)
        {
            _entry = entry;

            var config = entry.Protections;
            txtTitle.IsProtected = config.Title;
            txtPassword.IsProtected = config.Password;
            txtUsername.IsProtected = config.UserName;

            _binding = new EntryBinding(entry);
            _binding.HasChangesChanged += _binding_HasChangesChanged;
            _binding.HasChanges = entry.IsNew();

            CurrentEntry.Entry = _binding;
            _binding.HasChanges = entry.IsNew();

            UpdateNotes();
            DataContext = _binding;
        }
コード例 #20
0
ファイル: EntryDetails.xaml.cs プロジェクト: gkardava/WinPass
        protected override void OnNavigatedTo(
            bool cancelled, NavigationEventArgs e)
        {
            if (cancelled)
                return;

            if (_binding != null)
            {
                _binding.Save();

                UpdateNotes();

                if (!String.IsNullOrEmpty(_binding.Password))
                {
                    txtPassword.Text = _binding.Password;
                }

                return;
            }

            DateTime convertedDate;
            if ((Cache.DbInfo != null) && (Cache.DbInfo.Details.Modified != null))
            {
                convertedDate = DateTime.Parse(Cache.DbInfo.Details.Modified);
                ApplicationTitle.Text = "WinPass - " + Cache.DbInfo.Details.Name + " (" + convertedDate + ")";
            }

            var database = Cache.Database;
            if (database == null)
            {
                this.BackToDBs();
                return;
            }

            string id;
            var queries = NavigationContext.QueryString;
            _fields = new ObservableCollection<FieldBinding>();
            Entry entry;
            if (queries.TryGetValue("id", out id))
            {
                entry = database.GetEntry(id);

                ThreadPool.QueueUserWorkItem(
                    _ => Cache.AddRecent(id));

                // Notes
                if (!String.IsNullOrEmpty(entry.Notes))
                    txtNotes.Text = entry.Notes;

                // Fields
                _fields = new ObservableCollection
                    <FieldBinding>(entry.CustomFields
                        .Select(x => new FieldBinding(x)));


            }
            else
            {
                var config = database.Configuration;

                entry = new Entry
                {
                    Password = Generator
                        .CharacterSets.NewEntry(),
                    UserName = config.DefaultUserName,
                    Protections =
                        {
                            Title = config.ProtectTitle,
                            UserName = config.ProtectUserName,
                            Password = config.ProtectPassword,
                        }
                };

                txtTitle.Loaded += (sender, e1) =>
                    txtTitle.Focus();
            }
            lstFields.ItemsSource = _fields;
            DisplayEntry(entry);
        }
コード例 #21
0
ファイル: Group.cs プロジェクト: AFPass/7Pass
        /// <summary>
        /// Adds the specified entry.
        /// </summary>
        /// <param name="entry">The entry.</param>
        public void Add(Entry entry)
        {
            if (entry == null)
                throw new ArgumentNullException("entry");

            entry.Group = this;
            _entries.Add(entry);
        }
コード例 #22
0
ファイル: Database.cs プロジェクト: nthobois/7Pass
        /// <summary>
        /// Adds the new entry.
        /// </summary>
        /// <param name="entry">The entry.</param>
        /// <param name="groupId">The group id.</param>
        public void AddNew(Entry entry, string groupId)
        {
            if (entry == null)
                throw new ArgumentNullException("entry");

            var group = !string.IsNullOrEmpty(groupId)
                ? _groups[groupId] : _root;

            entry.ID = Uuid.NewUuid();
            entry.Group = group;

            group.Entries.Add(entry);
            _entries.Add(entry.ID, entry);
        }
コード例 #23
0
ファイル: Database.cs プロジェクト: nthobois/7Pass
 /// <summary>
 /// Removes the specified entry.
 /// </summary>
 /// <param name="entry">The entry.</param>
 public void Remove(Entry entry)
 {
     entry.Remove();
     _entries.Remove(entry.ID);
 }
コード例 #24
0
ファイル: DatabaseWriter.cs プロジェクト: AFPass/7Pass
 /// <summary>
 /// Saves the new entry.
 /// </summary>
 /// <param name="entry">The entry.</param>
 public void New(Entry entry)
 {
     _xmlWriter.New(entry);
 }
コード例 #25
0
ファイル: XmlWriter.cs プロジェクト: oldlaurel/WinPass
        /// <summary>
        /// Updates the location of the specified entry.
        /// </summary>
        /// <param name="entry">The entry.</param>
        public void Location(Entry entry)
        {
            if (entry == null)
                throw new ArgumentNullException("entry");

            var element = _entries[entry.ID];
            element.Remove();

            var parent = _groups[entry.Group.ID];
            parent.Add(element);

            var time = DateTime.Now;
            entry.LastModified = time;

            element
                .Element("Times")
                .Element("LocationChanged")
                .Value = GetTime(time);
        }
コード例 #26
0
ファイル: DatabaseWriter.cs プロジェクト: AFPass/7Pass
 /// <summary>
 /// Updates the details of the specified entry.
 /// </summary>
 /// <param name="entry">The entry.</param>
 public void Details(Entry entry)
 {
     _xmlWriter.Details(entry);
 }
コード例 #27
0
ファイル: Search.xaml.cs プロジェクト: oldlaurel/WinPass
 private static bool Matches(
     Entry entry, string text)
 {
     var settings = AppSettings.Instance;
     if (settings.SearchInPW)
     {
         return Matches(text, new[]
         {
             entry.Title,
             entry.UserName,
             entry.Password,
             entry.Notes,
         });
     }
     else
     {
         return Matches(text, new[]
     {
         entry.Title,
         entry.UserName,
         entry.Notes,
     });
     }            
 }