rust_rcs_client/messaging/ft_http/
config.rs

1// Copyright 2023 宋昊文
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use crate::provisioning::rcs_application::RcsApplication;
16
17pub struct FileTransferOverHTTPConfigs {
18    pub ft_auth: u32,
19
20    pub ft_warn_size: u32,
21    pub max_size_file_tr: u32,
22    pub ft_aut_accept: u32,
23
24    pub ft_http_cs_uri: Option<String>,
25    pub ft_http_dl_uri: Option<String>,
26    pub ft_http_cs_user: Option<String>,
27    pub ft_http_cs_pwd: Option<String>,
28    pub ft_http_fallback: Option<String>,
29
30    pub ft_max_1_to_many_recipients: u32,
31}
32
33impl FileTransferOverHTTPConfigs {
34    pub fn new() -> FileTransferOverHTTPConfigs {
35        FileTransferOverHTTPConfigs {
36            ft_auth: 0,
37
38            ft_warn_size: 0,
39            max_size_file_tr: 0,
40            ft_aut_accept: 0,
41
42            ft_http_cs_uri: None,
43            ft_http_dl_uri: None,
44            ft_http_cs_user: None,
45            ft_http_cs_pwd: None,
46            ft_http_fallback: None,
47
48            ft_max_1_to_many_recipients: 0,
49        }
50    }
51
52    pub fn update_configuration(&mut self, rcs_app: &RcsApplication) {
53        if let Some(messaging_config) = rcs_app.get_messaging_config() {
54            if let Some(services_config) = rcs_app.get_services_config() {
55                self.ft_auth = services_config.get_ft_auth();
56            }
57
58            if let Some(file_transfer_config) = messaging_config.get_file_transfer_config() {
59                self.ft_warn_size = file_transfer_config.get_ft_warn_size();
60                self.max_size_file_tr = file_transfer_config.get_max_size_file_tr();
61                self.ft_aut_accept = file_transfer_config.get_ft_aut_accept();
62
63                self.ft_http_cs_uri = file_transfer_config.get_ft_http_cs_uri();
64                self.ft_http_dl_uri = file_transfer_config.get_ft_http_dl_uri();
65                self.ft_http_cs_user = file_transfer_config.get_ft_http_cs_user();
66                self.ft_http_cs_pwd = file_transfer_config.get_ft_http_cs_pwd();
67                self.ft_http_fallback = file_transfer_config.get_ft_http_fallback();
68
69                self.ft_max_1_to_many_recipients =
70                    file_transfer_config.get_ft_max_1_to_many_recipients();
71            }
72        }
73    }
74}