WIP
This commit is contained in:
@@ -1 +1,55 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use nix::libc::uid_t;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct FingerPerson {
|
||||
/// User id
|
||||
uid: uid_t,
|
||||
/// User' home directory
|
||||
dir: PathBuf,
|
||||
/// Home phone no.
|
||||
homephone: String,
|
||||
/// Login name
|
||||
name: String,
|
||||
/// Office name
|
||||
office: String,
|
||||
/// Office phone no.
|
||||
officephone: String,
|
||||
/// Full name
|
||||
realname: String,
|
||||
/// User's shell
|
||||
shell: String,
|
||||
/// Last time mail was read
|
||||
mailread: DateTime<Utc>,
|
||||
/// Last time mail was received
|
||||
mailrecv: DateTime<Utc>,
|
||||
/// List of where the user is or has been
|
||||
where_: Vec<FingerWhere>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct FingerWhere {
|
||||
/// Type/status of request
|
||||
status: FingerWhereStatus,
|
||||
/// Tty is writable
|
||||
writable: bool,
|
||||
/// Time of (last) login
|
||||
loginat: DateTime<Utc>,
|
||||
/// how long idle (if logged in)
|
||||
idletime: DateTime<Utc>,
|
||||
// TODO: are technically limited by UT_LINESIZE and UT_HOSTSIZE
|
||||
/// Tty line
|
||||
tty: String,
|
||||
/// Remote hostname
|
||||
host: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[repr(C)]
|
||||
pub enum FingerWhereStatus {
|
||||
LastLog,
|
||||
LoggedIn,
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@ use serde::{Deserialize, Serialize};
|
||||
use zlink::{ReplyError, service::MethodReply};
|
||||
|
||||
use crate::{
|
||||
proto::{WhodStatusUpdate, WhodUserEntry},
|
||||
proto::{WhodStatusUpdate, WhodUserEntry, finger_protocol::FingerPerson},
|
||||
server::rwhod::RwhodStatusStore,
|
||||
};
|
||||
|
||||
// Types for 'no.ntnu.pvv.roowho2.rwhod'
|
||||
|
||||
#[zlink::proxy("no.ntnu.pvv.roowho2.rwhod")]
|
||||
pub trait RwhodClientProxy {
|
||||
async fn rwho(
|
||||
@@ -40,12 +42,69 @@ pub enum RwhodClientResponse {
|
||||
pub type RwhoResponse = Vec<(String, WhodUserEntry)>;
|
||||
pub type RuptimeResponse = Vec<WhodStatusUpdate>;
|
||||
|
||||
#[derive(Debug, ReplyError)]
|
||||
#[derive(Debug, Clone, PartialEq, ReplyError)]
|
||||
#[zlink(interface = "no.ntnu.pvv.roowho2.rwhod")]
|
||||
pub enum RwhodClientError {
|
||||
InvalidRequest,
|
||||
}
|
||||
|
||||
// Types for 'no.ntnu.pvv.roowho2.finger'
|
||||
|
||||
#[zlink::proxy("no.ntnu.pvv.roowho2.finger")]
|
||||
pub trait FingerClientProxy {
|
||||
async fn finger(
|
||||
&mut self,
|
||||
user_queries: Vec<String>,
|
||||
) -> zlink::Result<Result<Vec<FingerPerson>, FingerClientError>>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(tag = "method", content = "parameters")]
|
||||
pub enum FingerClientRequest {
|
||||
#[serde(rename = "no.ntnu.pvv.roowho2.finger.Finger")]
|
||||
Finger { user_queries: Vec<String> },
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum FingerClientResponse {
|
||||
Finger(FingerResponse),
|
||||
}
|
||||
|
||||
pub type FingerResponse = Vec<FingerPerson>;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, ReplyError)]
|
||||
#[zlink(interface = "no.ntnu.pvv.roowho2.finger")]
|
||||
pub enum FingerClientError {
|
||||
InvalidRequest,
|
||||
}
|
||||
|
||||
// --------------------
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
#[allow(unused)]
|
||||
enum Method {
|
||||
Rwhod(RwhodClientRequest),
|
||||
Finger(FingerClientRequest),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged)]
|
||||
#[allow(unused)]
|
||||
enum Reply {
|
||||
Rwhod(RwhodClientResponse),
|
||||
Finger(FingerClientResponse),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[serde(untagged)]
|
||||
#[allow(unused)]
|
||||
enum ReplyError {
|
||||
Rwhod(RwhodClientError),
|
||||
Finger(FingerClientError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Roowhoo2ClientServer {
|
||||
whod_status_store: RwhodStatusStore,
|
||||
|
||||
Reference in New Issue
Block a user