31 lines
982 B
C#
31 lines
982 B
C#
|
|
namespace Logic;
|
||
|
|
|
||
|
|
public class SecretService : ISecretService
|
||
|
|
{
|
||
|
|
Secret.Service service;
|
||
|
|
|
||
|
|
public SecretService()
|
||
|
|
{
|
||
|
|
Secret.Module.Initialize();
|
||
|
|
service = Secret.Service.GetSync(Secret.ServiceFlags.LoadCollections, null);
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<Secret.Collection> GetCollections()
|
||
|
|
{
|
||
|
|
GLib.List collections = service.GetCollections() ?? throw new Exception("No collections found");
|
||
|
|
List<Secret.Collection> result = new List<Secret.Collection>();
|
||
|
|
GLib.List.Foreach(collections, data =>
|
||
|
|
{
|
||
|
|
Secret.Collection collection = (Secret.Collection)GObject.Internal.InstanceWrapper.WrapHandle<Secret.Collection>(data, false);
|
||
|
|
result.Add(collection);
|
||
|
|
Console.WriteLine($" - {collection.Label}");
|
||
|
|
});
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void CreateCollection(string label)
|
||
|
|
{
|
||
|
|
Secret.Collection.CreateSync(service, label, null, Secret.CollectionCreateFlags.None, null);
|
||
|
|
}
|
||
|
|
}
|