updating doc
This commit is contained in:
112
docs/API.md
112
docs/API.md
@@ -13,6 +13,8 @@ who want to integrate with, extend, or understand the facial authentication syst
|
||||
- [Extension Points](#extension-points)
|
||||
- [Configuration](#configuration)
|
||||
- [IPC Protocol](#ipc-protocol)
|
||||
- [D-Bus API](#d-bus-api)
|
||||
- [Error Handling](#error-handling)
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
@@ -416,6 +418,116 @@ The daemon communicates via Unix socket using JSON messages.
|
||||
}
|
||||
```
|
||||
|
||||
## D-Bus API
|
||||
|
||||
The daemon exposes a D-Bus interface for desktop integration.
|
||||
|
||||
### Service Information
|
||||
|
||||
| Property | Value |
|
||||
|----------|-------|
|
||||
| Bus | System bus |
|
||||
| Service Name | `org.linuxhello.Daemon` |
|
||||
| Object Path | `/org/linuxhello/Manager` |
|
||||
| Interface | `org.linuxhello.Manager` |
|
||||
|
||||
### Methods
|
||||
|
||||
```xml
|
||||
<!-- Authenticate a user -->
|
||||
<method name="Authenticate">
|
||||
<arg name="user" type="s" direction="in"/>
|
||||
<arg name="success" type="b" direction="out"/>
|
||||
<arg name="confidence" type="d" direction="out"/>
|
||||
<arg name="message" type="s" direction="out"/>
|
||||
</method>
|
||||
|
||||
<!-- Start enrollment -->
|
||||
<method name="EnrollStart">
|
||||
<arg name="user" type="s" direction="in"/>
|
||||
<arg name="label" type="s" direction="in"/>
|
||||
<arg name="frame_count" type="u" direction="in"/>
|
||||
<arg name="success" type="b" direction="out"/>
|
||||
</method>
|
||||
|
||||
<!-- Cancel enrollment -->
|
||||
<method name="EnrollCancel">
|
||||
<arg name="success" type="b" direction="out"/>
|
||||
</method>
|
||||
|
||||
<!-- List templates for user -->
|
||||
<method name="ListTemplates">
|
||||
<arg name="user" type="s" direction="in"/>
|
||||
<arg name="templates" type="as" direction="out"/>
|
||||
</method>
|
||||
|
||||
<!-- Remove a template -->
|
||||
<method name="RemoveTemplate">
|
||||
<arg name="user" type="s" direction="in"/>
|
||||
<arg name="label" type="s" direction="in"/>
|
||||
<arg name="success" type="b" direction="out"/>
|
||||
</method>
|
||||
|
||||
<!-- Get system status -->
|
||||
<method name="GetSystemStatus">
|
||||
<arg name="camera_available" type="b" direction="out"/>
|
||||
<arg name="tpm_available" type="b" direction="out"/>
|
||||
<arg name="anti_spoofing_enabled" type="b" direction="out"/>
|
||||
<arg name="enrolled_count" type="u" direction="out"/>
|
||||
</method>
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
```xml
|
||||
<property name="Version" type="s" access="read"/>
|
||||
<property name="CameraAvailable" type="b" access="read"/>
|
||||
<property name="TpmAvailable" type="b" access="read"/>
|
||||
<property name="AntiSpoofingEnabled" type="b" access="read"/>
|
||||
```
|
||||
|
||||
### Signals
|
||||
|
||||
```xml
|
||||
<!-- Enrollment progress -->
|
||||
<signal name="EnrollmentProgress">
|
||||
<arg name="frames_captured" type="u"/>
|
||||
<arg name="frames_total" type="u"/>
|
||||
<arg name="status" type="s"/>
|
||||
</signal>
|
||||
|
||||
<!-- Enrollment complete -->
|
||||
<signal name="EnrollmentComplete">
|
||||
<arg name="success" type="b"/>
|
||||
<arg name="message" type="s"/>
|
||||
</signal>
|
||||
```
|
||||
|
||||
### D-Bus Client Example (Rust with zbus)
|
||||
|
||||
```rust
|
||||
use zbus::{Connection, proxy};
|
||||
|
||||
#[proxy(
|
||||
interface = "org.linuxhello.Manager",
|
||||
default_service = "org.linuxhello.Daemon",
|
||||
default_path = "/org/linuxhello/Manager"
|
||||
)]
|
||||
trait LinuxHelloManager {
|
||||
async fn authenticate(&self, user: &str) -> zbus::Result<(bool, f64, String)>;
|
||||
async fn list_templates(&self, user: &str) -> zbus::Result<Vec<String>>;
|
||||
}
|
||||
|
||||
async fn authenticate_user() -> zbus::Result<()> {
|
||||
let connection = Connection::system().await?;
|
||||
let proxy = LinuxHelloManagerProxy::new(&connection).await?;
|
||||
|
||||
let (success, confidence, message) = proxy.authenticate("alice").await?;
|
||||
println!("Auth: {} ({}): {}", success, confidence, message);
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
All operations return `Result<T, Error>` where `Error` is defined in `linux_hello_common::Error`:
|
||||
|
||||
Reference in New Issue
Block a user