use libcwtch::event::{ContactIdentity};
pub struct AllowListMembers {
pub peers: Vec<ContactIdentity>,
}
impl AllowListMembers {
pub fn new(peers: Vec<ContactIdentity>) -> Self {
AllowListMembers {peers: peers}
}
}
pub enum NewContactPolicy {
Ignore,
Block,
Accept,
AllowList
}
pub enum ContactInteractionPolicy {
Ignore,
Accept,
AcceptFromContact,
AllowList
}
pub enum GroupInvitePolicy {
Ignore,
Accept,
AcceptFromContact,
AllowList,
}
pub enum GroupInteractionPolicy {
Ignore,
Accept,
AcceptFromContact,
AllowList
}
pub struct Behaviour {
pub proto_experiments: bool,
pub proto_experiment_fileshare: bool,
pub proto_experiment_groups: bool,
pub profile_name: String,
pub profile_pic_path: Option<String>,
pub new_contant_policy: NewContactPolicy,
pub contact_interaction_policy: ContactInteractionPolicy,
pub group_invite_policy: GroupInvitePolicy,
pub group_interaction_policy: GroupInteractionPolicy,
pub allow_list: AllowListMembers,
}
pub struct BehaviourBuilder {
behaviour: Behaviour,
}
impl BehaviourBuilder {
pub fn new() -> Self {
return BehaviourBuilder {
behaviour: Behaviour {
proto_experiments: false,
proto_experiment_fileshare: false,
proto_experiment_groups: false,
new_contant_policy: NewContactPolicy::Ignore,
contact_interaction_policy: ContactInteractionPolicy::Ignore,
group_invite_policy: GroupInvitePolicy::Ignore,
group_interaction_policy: GroupInteractionPolicy::Ignore,
profile_name: "".to_string(),
profile_pic_path: None,
allow_list: AllowListMembers::new(vec!()),
},
};
}
pub fn build(self) -> Behaviour {
self.behaviour
}
pub fn groups(mut self, val: bool) -> Self {
self.behaviour.proto_experiment_groups = val;
self.behaviour.proto_experiments = true;
self
}
pub fn fileshare(mut self, val: bool) -> Self {
self.behaviour.proto_experiment_fileshare = val;
self.behaviour.proto_experiments = true;
self
}
pub fn profile_pic_path(mut self, val: String) -> Self {
self.behaviour.profile_pic_path = Some(val);
self.behaviour.proto_experiment_fileshare = true;
self.behaviour.proto_experiments = true;
self
}
pub fn name(mut self, val: String) -> Self {
self.behaviour.profile_name = val;
self
}
pub fn new_contact_policy(mut self, val: NewContactPolicy) -> Self {
self.behaviour.new_contant_policy = val;
self
}
pub fn contact_interaction_policy(mut self, val: ContactInteractionPolicy) -> Self {
self.behaviour.contact_interaction_policy = val;
self
}
pub fn group_invite_policy(mut self, val: GroupInvitePolicy) -> Self {
self.behaviour.group_invite_policy = val;
self
}
pub fn group_interaction_policy(mut self, val: GroupInteractionPolicy) -> Self {
self.behaviour.group_interaction_policy = val;
self
}
pub fn allow_list(mut self, val: AllowListMembers) -> Self {
self.behaviour.allow_list = val;
self
}
}