Esempio n. 1
0
        public static List <LoginSimplified> TurnIntoUICompatible(List <LoginInformation> loginInformations, List <LoginInformationSecret> loginInformationSecrets, Dictionary <string, byte[]> derivedPasswords, SettingsData settingsData)
        {
            List <LoginSimplified> returnList = new List <LoginSimplified>();

            if (loginInformations != null && loginInformations.Count > 0)
            {
                int runningIndexNumber = 0;
                foreach (LoginInformation loginInformation in loginInformations)
                {
                    returnList.Add(new LoginSimplified()
                    {
                        zeroBasedIndexNumber = runningIndexNumber,
                        IsSecure             = false,
                        Title            = UITextFormat.FormatTextWithFilter(loginInformation.GetTitle(), settingsData.LoginTitleShowMode),
                        URL              = UITextFormat.FormatTextWithFilter(loginInformation.GetURL(), settingsData.LoginUrlShowMode),
                        Email            = UITextFormat.FormatTextWithFilter(loginInformation.GetEmail(), settingsData.LoginEmailShowMode),
                        Username         = UITextFormat.FormatTextWithFilter(loginInformation.GetUsername(), settingsData.LoginUsernameShowMode),
                        Password         = UITextFormat.FormatTextWithFilter(loginInformation.GetPassword(), settingsData.LoginPasswordShowMode),
                        Notes            = loginInformation.GetNotes(),
                        Icon             = loginInformation.GetIcon(),
                        Category         = UITextFormat.FormatTextWithFilter(loginInformation.GetCategory(), settingsData.LoginCategoryShowMode),
                        Tags             = loginInformation.GetTags(),
                        CreationTime     = loginInformation.GetCreationTime().ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                        ModificationTime = loginInformation.GetModificationTime().ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                    });

                    runningIndexNumber++;
                }
            }

            if (loginInformationSecrets != null && loginInformationSecrets.Count > 0)
            {
                int runningIndexNumber = 0;
                foreach (LoginInformationSecret loginInformationSecret in loginInformationSecrets)
                {
                    byte[] derivedPassword = derivedPasswords[loginInformationSecret.GetKeyIdentifier()];
                    returnList.Add(new LoginSimplified()
                    {
                        zeroBasedIndexNumber = runningIndexNumber,
                        IsSecure             = true,
                        Title            = UITextFormat.FormatTextWithFilter(loginInformationSecret.GetTitle(derivedPassword), settingsData.LoginTitleShowMode),
                        URL              = UITextFormat.FormatTextWithFilter(loginInformationSecret.GetURL(derivedPassword), settingsData.LoginUrlShowMode),
                        Email            = UITextFormat.FormatTextWithFilter(loginInformationSecret.GetEmail(derivedPassword), settingsData.LoginEmailShowMode),
                        Username         = UITextFormat.FormatTextWithFilter(loginInformationSecret.GetUsername(derivedPassword), settingsData.LoginUsernameShowMode),
                        Password         = UITextFormat.FormatTextWithFilter(loginInformationSecret.GetPassword(derivedPassword), settingsData.LoginPasswordShowMode),
                        Notes            = loginInformationSecret.GetNotes(derivedPassword),
                        Icon             = loginInformationSecret.GetIcon(derivedPassword),
                        Category         = UITextFormat.FormatTextWithFilter(loginInformationSecret.GetCategory(derivedPassword), settingsData.LoginCategoryShowMode),
                        Tags             = loginInformationSecret.GetTags(derivedPassword),
                        CreationTime     = loginInformationSecret.GetCreationTime(derivedPassword).ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                        ModificationTime = loginInformationSecret.GetModificationTime(derivedPassword).ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                    });

                    runningIndexNumber++;
                }
            }

            return(returnList);
        }
        public static List <FileSimplified> TurnIntoUICompatible(List <FileEntry> files, List <FileEntrySecret> fileSecrets, Dictionary <string, byte[]> derivedPasswords, SettingsData settingsData)
        {
            List <FileSimplified> returnList = new List <FileSimplified>();

            if (files != null && files.Count > 0)
            {
                int runningIndexNumber = 0;
                foreach (FileEntry file in files)
                {
                    returnList.Add(new FileSimplified()
                    {
                        zeroBasedIndexNumber = runningIndexNumber,
                        IsSecure             = false,
                        Filename             = UITextFormat.FormatTextWithFilter(file.GetFilename(), settingsData.FileFilenameShowMode),
                        Filesize             = "N/A",
                        Filetype             = "N/A",
                        CreationTime         = file.GetCreationTime().ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                        ModificationTime     = file.GetModificationTime().ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                    });

                    runningIndexNumber++;
                }
            }

            if (fileSecrets != null && fileSecrets.Count > 0)
            {
                int runningIndexNumber = 0;
                foreach (FileEntrySecret fileSecret in fileSecrets)
                {
                    byte[] derivedPassword = derivedPasswords[fileSecret.GetKeyIdentifier()];
                    returnList.Add(new FileSimplified()
                    {
                        zeroBasedIndexNumber = runningIndexNumber,
                        IsSecure             = true,
                        Filename             = UITextFormat.FormatTextWithFilter(fileSecret.GetFilename(derivedPassword), settingsData.FileFilenameShowMode),
                        Filesize             = "N/A",
                        Filetype             = "N/A",
                        CreationTime         = fileSecret.GetCreationTime(derivedPassword).ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                        ModificationTime     = fileSecret.GetModificationTime(derivedPassword).ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                    });

                    runningIndexNumber++;
                }
            }

            return(returnList);
        }
        public static List <NoteSimplified> TurnIntoUICompatible(List <Note> notes, List <NoteSecret> noteSecrets, Dictionary <string, byte[]> derivedPasswords, SettingsData settingsData)
        {
            List <NoteSimplified> returnList = new List <NoteSimplified>();

            if (notes != null && notes.Count > 0)
            {
                int runningIndexNumber = 0;
                foreach (Note note in notes)
                {
                    returnList.Add(new NoteSimplified()
                    {
                        zeroBasedIndexNumber = runningIndexNumber,
                        IsSecure             = false,
                        Title            = UITextFormat.FormatTextWithFilter(note.GetNoteTitle(), settingsData.NoteTitleShowMode),
                        Text             = UITextFormat.FormatTextWithFilter(note.GetNoteText(), settingsData.NoteTextShowMode),
                        CreationTime     = note.GetCreationTime().ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                        ModificationTime = note.GetModificationTime().ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                    });

                    runningIndexNumber++;
                }
            }

            if (noteSecrets != null && noteSecrets.Count > 0)
            {
                int runningIndexNumber = 0;
                foreach (NoteSecret noteSecret in noteSecrets)
                {
                    byte[] derivedPassword = derivedPasswords[noteSecret.GetKeyIdentifier()];
                    returnList.Add(new NoteSimplified()
                    {
                        zeroBasedIndexNumber = runningIndexNumber,
                        IsSecure             = true,
                        Title            = UITextFormat.FormatTextWithFilter(noteSecret.GetNoteTitle(derivedPassword), settingsData.NoteTitleShowMode),
                        Text             = UITextFormat.FormatTextWithFilter(noteSecret.GetNoteText(derivedPassword), settingsData.NoteTextShowMode),
                        CreationTime     = noteSecret.GetCreationTime(derivedPassword).ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                        ModificationTime = noteSecret.GetModificationTime(derivedPassword).ToString("s", System.Globalization.CultureInfo.InvariantCulture),
                    });

                    runningIndexNumber++;
                }
            }

            return(returnList);
        }