Renamed service
This commit is contained in:
@@ -15,7 +15,7 @@ class Program
|
|||||||
var application = Adw.Application.New("org.typomustakes.keychain", Gio.ApplicationFlags.FlagsNone);
|
var application = Adw.Application.New("org.typomustakes.keychain", Gio.ApplicationFlags.FlagsNone);
|
||||||
application.OnActivate += (sender, args) =>
|
application.OnActivate += (sender, args) =>
|
||||||
{
|
{
|
||||||
var passwordStoreService = provider.GetRequiredService<IPasswordStoreService>();
|
var passwordStoreService = provider.GetRequiredService<ICollectionsService>();
|
||||||
var window = new UI.MainWindow(passwordStoreService).Window;
|
var window = new UI.MainWindow(passwordStoreService).Window;
|
||||||
window.Application = (Adw.Application)sender;
|
window.Application = (Adw.Application)sender;
|
||||||
window.Show();
|
window.Show();
|
||||||
@@ -27,7 +27,7 @@ class Program
|
|||||||
private static ServiceProvider SetupServices()
|
private static ServiceProvider SetupServices()
|
||||||
{
|
{
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
services.AddSingleton<IPasswordStoreService, PasswordStoreService>();
|
services.AddSingleton<ICollectionsService, CollectionsService>();
|
||||||
services.AddSingleton<IBookmarksRepository, BookmarksRepository>();
|
services.AddSingleton<IBookmarksRepository, BookmarksRepository>();
|
||||||
services.AddSingleton<ISecretService, SecretService>();
|
services.AddSingleton<ISecretService, SecretService>();
|
||||||
return services.BuildServiceProvider();
|
return services.BuildServiceProvider();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public partial class MainWindow
|
|||||||
private const string searchEntryId = "search_entry";
|
private const string searchEntryId = "search_entry";
|
||||||
private const string passwordListId = "password_list";
|
private const string passwordListId = "password_list";
|
||||||
|
|
||||||
public MainWindow(IPasswordStoreService passwordStoreService)
|
public MainWindow(ICollectionsService passwordStoreService)
|
||||||
{
|
{
|
||||||
this.passwordStoreService = passwordStoreService;
|
this.passwordStoreService = passwordStoreService;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Keychain.UI;
|
|||||||
public partial class MainWindow
|
public partial class MainWindow
|
||||||
{
|
{
|
||||||
private const string DEFAULT_SHORTCUT_NAME = "Keychain";
|
private const string DEFAULT_SHORTCUT_NAME = "Keychain";
|
||||||
private readonly IPasswordStoreService passwordStoreService;
|
private readonly ICollectionsService passwordStoreService;
|
||||||
|
|
||||||
private PreferencesGroup shortcutsGroup;
|
private PreferencesGroup shortcutsGroup;
|
||||||
private BookmarkCollection shortcuts;
|
private BookmarkCollection shortcuts;
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ using System.Collections.Specialized;
|
|||||||
|
|
||||||
public class BookmarkCollection : ObservableCollection<BookmarkViewModel>
|
public class BookmarkCollection : ObservableCollection<BookmarkViewModel>
|
||||||
{
|
{
|
||||||
private readonly IPasswordStoreService _passwordStoreService;
|
private readonly ICollectionsService _passwordStoreService;
|
||||||
|
|
||||||
private readonly PreferencesGroup shortcutsGroup;
|
private readonly PreferencesGroup shortcutsGroup;
|
||||||
private Dictionary<BookmarkViewModel, ActionRow> itemToRowMap = new();
|
private Dictionary<BookmarkViewModel, ActionRow> itemToRowMap = new();
|
||||||
|
|
||||||
public BookmarkCollection(PreferencesGroup shortcutsGroup, IPasswordStoreService passwordStoreService)
|
public BookmarkCollection(PreferencesGroup shortcutsGroup, ICollectionsService passwordStoreService)
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
this.shortcutsGroup = shortcutsGroup;
|
this.shortcutsGroup = shortcutsGroup;
|
||||||
@@ -94,7 +94,9 @@ public class BookmarkCollection : ObservableCollection<BookmarkViewModel>
|
|||||||
public void Add(string path, string? displayName = null)
|
public void Add(string path, string? displayName = null)
|
||||||
{
|
{
|
||||||
BookmarkViewModel item = new BookmarkViewModel(path, displayName);
|
BookmarkViewModel item = new BookmarkViewModel(path, displayName);
|
||||||
Add(item);
|
if (_passwordStoreService.Create(item.Model))
|
||||||
_passwordStoreService.Create(item.Model);
|
{
|
||||||
|
Add(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,11 +8,11 @@ namespace Keychain.ViewModels;
|
|||||||
|
|
||||||
public class PasswordList : ObservableCollection<PasswordViewModel>
|
public class PasswordList : ObservableCollection<PasswordViewModel>
|
||||||
{
|
{
|
||||||
private readonly IPasswordStoreService _passwordService;
|
private readonly ICollectionsService _passwordService;
|
||||||
private readonly PreferencesGroup list;
|
private readonly PreferencesGroup list;
|
||||||
private Dictionary<PasswordViewModel, ActionRow> itemToRowMap = new();
|
private Dictionary<PasswordViewModel, ActionRow> itemToRowMap = new();
|
||||||
|
|
||||||
public PasswordList(PreferencesGroup list, IPasswordStoreService passwordService)
|
public PasswordList(PreferencesGroup list, ICollectionsService passwordService)
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
this.list = list;
|
this.list = list;
|
||||||
|
|||||||
@@ -3,21 +3,25 @@ using Repository;
|
|||||||
|
|
||||||
namespace Logic;
|
namespace Logic;
|
||||||
|
|
||||||
public class PasswordStoreService : IPasswordStoreService
|
public class CollectionsService : ICollectionsService
|
||||||
{
|
{
|
||||||
private readonly IBookmarksRepository repository;
|
private readonly IBookmarksRepository repository;
|
||||||
private readonly ISecretService secretService;
|
private readonly ISecretService secretService;
|
||||||
|
|
||||||
public PasswordStoreService(IBookmarksRepository repository, ISecretService secretService)
|
public CollectionsService(IBookmarksRepository repository, ISecretService secretService)
|
||||||
{
|
{
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
this.secretService = secretService;
|
this.secretService = secretService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Create(PasswordStore item)
|
public bool Create(PasswordStore item)
|
||||||
{
|
{
|
||||||
secretService.CreateCollection(item.DisplayName ?? item.Path);
|
if (secretService.CreateCollection(item.DisplayName ?? item.Path))
|
||||||
repository.Create(item);
|
{
|
||||||
|
repository.Create(item);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(uint ID)
|
public void Delete(uint ID)
|
||||||
@@ -2,12 +2,12 @@ using Models;
|
|||||||
|
|
||||||
namespace Logic;
|
namespace Logic;
|
||||||
|
|
||||||
public interface IPasswordStoreService
|
public interface ICollectionsService
|
||||||
{
|
{
|
||||||
IEnumerable<PasswordStore> GetAll();
|
IEnumerable<PasswordStore> GetAll();
|
||||||
PasswordStore Get(uint ID);
|
PasswordStore Get(uint ID);
|
||||||
void Delete(uint ID);
|
void Delete(uint ID);
|
||||||
void Delete(PasswordStore item);
|
void Delete(PasswordStore item);
|
||||||
void Create(PasswordStore item);
|
bool Create(PasswordStore item);
|
||||||
void Edit(uint ID, PasswordStore newItem);
|
void Edit(uint ID, PasswordStore newItem);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user