KeyBoxen 0.1.0

Standalone secret-service daemon for window managers
// Copyright (C) 2022 KeyBoxen Authors
// SPDX-License-Identifier: GPL-3.0-or-later

//! DBus service root module
//!
//! This module implements the root object and other objects that
//! represent the secret service on the session DBus. Its path is
//! `org/freedesktop/secrets`. Refer the [secret service
//! specification][ch12] for details
//!
//! [ch12]: https://specifications.freedesktop.org/secret-service/latest/ch12.html

use super::{DBusErrorKind, DBusSecret, Service};
use std::collections::HashMap;
use zbus::zvariant::{ObjectPath, Value};
use zbus::{dbus_interface, SignalContext};

impl Service {
    pub fn empty() -> Self {
        Self {
            collections: HashMap::new(),
            items: HashMap::new(),
            attributes: Vec::new(),
        }
    }
}

/// Root interface
///
/// This impl implements [the interface][re01] that manages all
/// sessions and collections.
///
/// [re01]: https://specifications.freedesktop.org/secret-service/latest/re01.html
#[allow(unused_variables, dead_code)] // Remove this after implementation
#[dbus_interface(name = "org.freedesktop.Secret.Service")]
impl Service {
    #[dbus_interface(out_args("output", "result"))]
    async fn open_session(
        &self,
        algorithm: &str,
        input: Value<'_>,
    ) -> Result<(Value, ObjectPath), DBusErrorKind> {
        unimplemented!()
    }

    #[dbus_interface(out_args("collection", "prompt"))]
    async fn create_collection(
        &self,
        properties: HashMap<String, Value<'_>>,
        alias: String,
    ) -> Result<(ObjectPath, ObjectPath), DBusErrorKind> {
        unimplemented!()
    }

    #[dbus_interface(out_args("unlocked", "locked"))]
    async fn search_items(
        &self,
        attributes: HashMap<String, String>,
    ) -> Result<(Vec<ObjectPath>, Vec<ObjectPath>), DBusErrorKind> {
        unimplemented!()
    }

    #[dbus_interface(out_args("unlocked", "prompt"))]
    async fn unlock(
        &self,
        objects: Vec<ObjectPath<'_>>,
    ) -> Result<(Vec<ObjectPath>, ObjectPath), DBusErrorKind> {
        unimplemented!()
    }

    #[dbus_interface(out_args("locked", "prompt"))]
    async fn lock(
        &self,
        objects: Vec<ObjectPath<'_>>,
    ) -> Result<(Vec<ObjectPath>, ObjectPath), DBusErrorKind> {
        unimplemented!()
    }

    #[dbus_interface(out_args("secrets"))]
    async fn get_secrets(
        &self,
        items: Vec<ObjectPath<'_>>,
        session: ObjectPath<'_>,
    ) -> Result<(HashMap<ObjectPath, DBusSecret>,), DBusErrorKind> {
        unimplemented!()
    }

    #[dbus_interface(out_args("collection"))]
    async fn read_alias(&self, name: String) -> Result<(ObjectPath,), DBusErrorKind> {
        unimplemented!()
    }

    async fn set_alias(
        &self,
        name: String,
        collection: ObjectPath<'_>,
    ) -> Result<(), DBusErrorKind> {
        unimplemented!()
    }

    #[dbus_interface(signal)]
    async fn collection_created(
        ctxt: &SignalContext<'_>,
        collection: ObjectPath<'_>,
    ) -> zbus::Result<()> {
        unimplemented!()
    }

    #[dbus_interface(signal)]
    async fn collection_deleted(
        ctxt: &SignalContext<'_>,
        collection: ObjectPath<'_>,
    ) -> zbus::Result<()> {
        unimplemented!()
    }

    #[dbus_interface(signal)]
    async fn collection_changed(
        ctxt: &SignalContext<'_>,
        collection: ObjectPath<'_>,
    ) -> zbus::Result<()> {
        unimplemented!()
    }

    #[dbus_interface(property)]
    async fn collections(&self) -> Vec<ObjectPath> {
        unimplemented!()
    }
}