aboutsummaryrefslogtreecommitdiff
path: root/src/message/signalproxy
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2020-10-16 21:58:05 +0200
committerMax Audron <audron@cocaine.farm>2020-10-16 21:58:05 +0200
commitfd943651195a970aac2b066e3bdbb23253f73ce7 (patch)
tree09af5399dcd96b8f525412798b7e6e8719f3e55e /src/message/signalproxy
parentupdate paperwork (diff)
update
Diffstat (limited to 'src/message/signalproxy')
-rw-r--r--src/message/signalproxy/mod.rs14
-rw-r--r--src/message/signalproxy/objects/aliasmanager.rs46
-rw-r--r--src/message/signalproxy/objects/backlogmanager.rs161
-rw-r--r--src/message/signalproxy/objects/mod.rs6
-rw-r--r--src/message/signalproxy/rpccall.rs45
-rw-r--r--src/message/signalproxy/syncmessage.rs2
6 files changed, 262 insertions, 12 deletions
diff --git a/src/message/signalproxy/mod.rs b/src/message/signalproxy/mod.rs
index b0fd9ea..b69c6b0 100644
--- a/src/message/signalproxy/mod.rs
+++ b/src/message/signalproxy/mod.rs
@@ -3,6 +3,7 @@ use crate::{Deserialize, Serialize};
mod heartbeat;
mod initdata;
mod initrequest;
+mod objects;
mod rpccall;
mod syncmessage;
@@ -26,6 +27,19 @@ pub enum Message {
HeartBeatReply(HeartBeatReply),
}
+// impl Message {
+// fn act(&self) {
+// match &self {
+// Message::SyncMessage(value) => value.serialize(),
+// Message::RpcCall(value) => value.serialize(),
+// Message::InitRequest(value) => value.serialize(),
+// Message::InitData(value) => value.serialize(),
+// Message::HeartBeat(value) => value.serialize(),
+// Message::HeartBeatReply(value) => value.serialize(),
+// }
+// }
+// }
+
impl Serialize for Message {
fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> {
match &self {
diff --git a/src/message/signalproxy/objects/aliasmanager.rs b/src/message/signalproxy/objects/aliasmanager.rs
new file mode 100644
index 0000000..7e9cfca
--- /dev/null
+++ b/src/message/signalproxy/objects/aliasmanager.rs
@@ -0,0 +1,46 @@
+use crate::primitive::{Variant, VariantMap};
+
+#[derive(Clone, Debug, std::cmp::PartialEq)]
+pub struct AliasManager {
+ pub aliases: Vec<Alias>,
+}
+
+#[derive(Clone, Debug, std::cmp::PartialEq)]
+pub struct Alias {
+ name: String,
+ expansion: String,
+}
+
+// impl AliasManager {
+// /// Client to Server
+// ///
+// /// Replaces all properties of the object with the content of the
+// /// "properties" parameter. This parameter is in network representation.
+// ///
+// fn request_update(self: Self, properties: VariantMap) {
+// self.update(properties);
+// }
+//
+// /// Server to Client
+// fn add_alias(self: Self, name: String, expansion: String) {
+// self.aliases.push(Alias { name, expansion });
+// }
+//
+// /// Server to Client
+// ///
+// /// Replaces all properties of the object with the content of the
+// /// "properties" parameter. This parameter is in network representation.
+// ///
+// fn update(self: Self, properties: VariantMap) {
+// let mut alias: Vec<Alias> = Vec::new();
+//
+// // for (i, name) in match_variant!(properties[&"Aliases".to_string()], Variant::String) {
+// // alias.push(Alias {
+// // name,
+// // expansion: match_variant!(properties["Aliases"], Variant::String)["expansions"][i],
+// // })
+// // }
+//
+// self.aliases = alias
+// }
+// }
diff --git a/src/message/signalproxy/objects/backlogmanager.rs b/src/message/signalproxy/objects/backlogmanager.rs
new file mode 100644
index 0000000..86a7f61
--- /dev/null
+++ b/src/message/signalproxy/objects/backlogmanager.rs
@@ -0,0 +1,161 @@
+// interface BacklogManager {
+//
+//
+// // C->S calls
+//
+// /**
+// * Loads backlog for `bufferId`, starting at message `first`, up to `last`
+// * (plus `additional` more messages after `last`) but at most `limit`
+// * messages total.
+// */
+// requestBacklog(bufferId: BufferId, first: MsgId, last: MsgId, limit: Int, additional: Int)
+// /**
+// * Same as `requestBacklog`, but only messages of a certain message `type`
+// * with certain `flags` set.
+// */
+// requestBacklogFiltered(bufferId: BufferId, first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int)
+// /**
+// * Same as `requestBacklog`, but applied to all buffers.
+// */
+// requestBacklogAll(first: MsgId, last: MsgId, limit: Int, additional: Int)
+// /**
+// * Same as `requestBacklogFiltered`, but applied to all buffers.
+// */
+// requestBacklogAllFiltered(first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int)
+//
+//
+// // S->C calls
+//
+// /**
+// * The response to `requestBacklog`, with the messages encoded as QVariants
+// * in the `messages` parameter.
+// */
+// receiveBacklog(bufferId: BufferId, first: MsgId, last: MsgId, limit: Int, additional: Int, messages: QVariantList)
+// /**
+// * The response to `requestBacklogFiltered`, with the messages encoded as
+// * QVariants in the `messages` parameter.
+// */
+// receiveBacklogFiltered(bufferId: BufferId, first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int, messages: QVariantList)
+// /**
+// * The response to `requestBacklogAll`, with the messages encoded as
+// * QVariants in the `messages` parameter.
+// */
+// receiveBacklogAll(first: MsgId, last: MsgId, limit: Int, additional: Int, messages: QVariantList)
+// /**
+// * The response to `requestBacklogAllFiltered`, with the messages encoded as
+// * QVariants in the `messages` parameter.
+// */
+// receiveBacklogAllFiltered(first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int, messages: QVariantList)
+// }
+
+use crate::primitive::VariantList;
+
+/// Receive and Request Backlog
+/// All "request" functions are Client to Server and all "receive" functions are Server to Client
+#[derive(Clone, Debug, std::cmp::PartialEq)]
+pub struct BacklogManager {}
+
+impl BacklogManager {
+ /// Loads backlog for `bufferId`, starting at message `first`, up to `last`
+ /// (plus `additional` more messages after `last`) but at most `limit`
+ /// messages total.
+ fn requestBacklog(
+ self: Self,
+ buffer_id: u32,
+ first: u32,
+ last: u32,
+ limit: u32,
+ additional: u32,
+ ) {
+ unimplemented!()
+ }
+
+ /// Same as `requestBacklog`, but only messages of a certain message `type`
+ /// with certain `flags` set.
+ fn requestBacklogFiltered(
+ self: Self,
+ buffer_id: u32,
+ first: u32,
+ last: u32,
+ limit: u32,
+ additional: u32,
+ msgtype: u32,
+ flags: u32,
+ ) {
+ unimplemented!()
+ }
+
+ /// Same as `requestBacklog`, but applied to all buffers.
+ fn requestBacklogAll(self: Self, first: u32, last: u32, limit: u32, additional: u32) {
+ unimplemented!()
+ }
+
+ /// Same as `requestBacklogFiltered`, but applied to all buffers.
+ fn requestBacklogAllFiltered(
+ self: Self,
+ first: u32,
+ last: u32,
+ limit: u32,
+ additional: u32,
+ msgtype: u32,
+ flags: u32,
+ ) {
+ unimplemented!()
+ }
+
+ /// The response to `requestBacklog`, with the messages encoded as Variants
+ /// in the `messages` parameter.
+ fn receiveBacklog(
+ self: Self,
+ buffer_id: u32,
+ first: u32,
+ last: u32,
+ limit: u32,
+ additional: u32,
+ messages: VariantList,
+ ) {
+ unimplemented!()
+ }
+
+ /// The response to `requestBacklogFiltered`, with the messages encoded as
+ /// Variants in the `messages` parameter.
+ fn receiveBacklogFiltered(
+ self: Self,
+ buffer_id: u32,
+ first: u32,
+ last: u32,
+ limit: u32,
+ additional: u32,
+ msgtype: u32,
+ flags: u32,
+ messages: VariantList,
+ ) {
+ unimplemented!()
+ }
+
+ /// Same as `receiveBacklog`, but applied to all buffers.
+ fn receiveBacklogAll(
+ self: Self,
+ first: u32,
+ last: u32,
+ limit: u32,
+ additional: u32,
+ messages: VariantList,
+ ) {
+ unimplemented!()
+ }
+
+ /// Same as `receiveBacklogFiltered`, but applied to all buffers.
+ fn receiveBacklogAllFiltered(
+ self: Self,
+ first: u32,
+ last: u32,
+ limit: u32,
+ additional: u32,
+ msgtype: u32,
+ flags: u32,
+ messages: VariantList,
+ ) {
+ unimplemented!()
+ }
+}
diff --git a/src/message/signalproxy/objects/mod.rs b/src/message/signalproxy/objects/mod.rs
new file mode 100644
index 0000000..14dc42f
--- /dev/null
+++ b/src/message/signalproxy/objects/mod.rs
@@ -0,0 +1,6 @@
+mod aliasmanager;
+mod backlogmanager;
+
+pub trait Act {
+ fn act(self: Self);
+}
diff --git a/src/message/signalproxy/rpccall.rs b/src/message/signalproxy/rpccall.rs
index 748b226..2eac86d 100644
--- a/src/message/signalproxy/rpccall.rs
+++ b/src/message/signalproxy/rpccall.rs
@@ -1,21 +1,36 @@
use crate::message::MessageType;
+use crate::primitive::Message;
use crate::primitive::{Variant, VariantList};
use crate::{Deserialize, Serialize};
#[derive(Clone, Debug, std::cmp::PartialEq)]
-pub struct RpcCall {
- slot_name: String,
- params: VariantList,
+pub enum RpcCall {
+ DisplayMessage(DisplayMessage),
}
+#[derive(Clone, Debug, std::cmp::PartialEq)]
+pub struct DisplayMessage {
+ pub message: Message,
+}
+
+// #[derive(Clone, Debug, std::cmp::PartialEq)]
+// pub struct RpcCall {
+// pub slot_name: String,
+// pub params: VariantList,
+// }
+
impl Serialize for RpcCall {
fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> {
let mut res = VariantList::new();
res.push(Variant::i32(MessageType::RpcCall as i32));
- res.push(Variant::StringUTF8(self.slot_name.clone()));
- res.append(&mut self.params.clone());
+ match self {
+ RpcCall::DisplayMessage(msg) => {
+ res.push(Variant::StringUTF8("2displayMsg(Message)".to_string()));
+ res.push(Variant::Message(msg.message.clone()));
+ }
+ }
res.serialize()
}
@@ -27,12 +42,18 @@ impl Deserialize for RpcCall {
res.remove(0);
- Ok((
- size,
- Self {
- slot_name: match_variant!(res.remove(0), Variant::StringUTF8),
- params: res,
- },
- ))
+ let rpc = match_variant!(res.remove(0), Variant::StringUTF8);
+
+ match rpc.as_str() {
+ "2displayMsg(Message)" => {
+ return Ok((
+ size,
+ RpcCall::DisplayMessage(DisplayMessage {
+ message: match_variant!(res.remove(0), Variant::Message),
+ }),
+ ))
+ }
+ _ => unimplemented!(),
+ }
}
}
diff --git a/src/message/signalproxy/syncmessage.rs b/src/message/signalproxy/syncmessage.rs
index fe69cf1..737f3e0 100644
--- a/src/message/signalproxy/syncmessage.rs
+++ b/src/message/signalproxy/syncmessage.rs
@@ -10,6 +10,8 @@ pub struct SyncMessage {
params: VariantList,
}
+// impl Act for SyncMessage {}
+
impl Serialize for SyncMessage {
fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> {
let mut res = VariantList::new();