• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
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  */
15 
16 #include "mms_header_categ.h"
17 
18 #include "map"
19 #include "utility"
20 
21 namespace OHOS {
22 namespace Telephony {
MmsHeaderCateg()23 MmsHeaderCateg::MmsHeaderCateg()
24 {
25     InitFieldDesMap();
26 
27     InitSendReqMap();
28     InitSendConfMap();
29 }
30 
~MmsHeaderCateg()31 MmsHeaderCateg::~MmsHeaderCateg()
32 {
33     mmsFieldDesMap_.clear();
34 
35     mmsSendReqOptMap_.clear();
36     mmsSendConfOptMap_.clear();
37 }
38 
InitFieldDesMap()39 void MmsHeaderCateg::InitFieldDesMap()
40 {
41     mmsFieldDesMap_.clear();
42     /* MMS 1.0 */
43     InitFieldDesV10();
44     /* MMS 1.1 */
45     InitFieldDesV11();
46     /* MMS 1.2 */
47     InitFieldDesV12();
48 }
49 
InitFieldDesV10()50 void MmsHeaderCateg::InitFieldDesV10()
51 {
52     /* MMS 1.0 */
53     mmsFieldDesMap_.emplace(MMS_BCC, MmsFieldValueType::MMS_FIELD_ENCODE_ADDR_TYPE);
54     mmsFieldDesMap_.emplace(MMS_CC, MmsFieldValueType::MMS_FIELD_ENCODE_ADDR_TYPE);
55     mmsFieldDesMap_.emplace(MMS_CONTENT_LOCATION, MmsFieldValueType::MMS_FIELD_TEXT_TYPE);
56     mmsFieldDesMap_.emplace(MMS_CONTENT_TYPE, MmsFieldValueType::MMS_FIELD_UNKOWN_TYPE);
57     mmsFieldDesMap_.emplace(MMS_DATE, MmsFieldValueType::MMS_FIELD_LONG_TYPE);
58     mmsFieldDesMap_.emplace(MMS_DELIVERY_REPORT, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
59     mmsFieldDesMap_.emplace(MMS_DELIVERY_TIME, MmsFieldValueType::MMS_FIELD_LONG_TYPE);
60     mmsFieldDesMap_.emplace(MMS_EXPIRY, MmsFieldValueType::MMS_FIELD_LONG_TYPE);
61     mmsFieldDesMap_.emplace(MMS_FROM, MmsFieldValueType::MMS_FIELD_ENCODE_ADDR_TYPE);
62     mmsFieldDesMap_.emplace(MMS_MESSAGE_CLASS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
63     mmsFieldDesMap_.emplace(MMS_MESSAGE_ID, MmsFieldValueType::MMS_FIELD_TEXT_TYPE);
64     mmsFieldDesMap_.emplace(MMS_MESSAGE_TYPE, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
65     mmsFieldDesMap_.emplace(MMS_MMS_VERSION, MmsFieldValueType::MMS_FIELD_INTEGER_TYPE);
66     mmsFieldDesMap_.emplace(MMS_MESSAGE_SIZE, MmsFieldValueType::MMS_FIELD_LONG_TYPE);
67     mmsFieldDesMap_.emplace(MMS_PRIORITY, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
68     mmsFieldDesMap_.emplace(MMS_READ_REPORT, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
69     mmsFieldDesMap_.emplace(MMS_REPORT_ALLOWED, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
70     mmsFieldDesMap_.emplace(MMS_RESPONSE_STATUS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
71     mmsFieldDesMap_.emplace(MMS_RESPONSE_TEXT, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
72     mmsFieldDesMap_.emplace(MMS_SENDER_VISIBILITY, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
73     mmsFieldDesMap_.emplace(MMS_STATUS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
74     mmsFieldDesMap_.emplace(MMS_SUBJECT, MmsFieldValueType::MMS_FIELD_ENCODE_TEXT_TYPE);
75     mmsFieldDesMap_.emplace(MMS_TO, MmsFieldValueType::MMS_FIELD_ENCODE_ADDR_TYPE);
76     mmsFieldDesMap_.emplace(MMS_TRANSACTION_ID, MmsFieldValueType::MMS_FIELD_TEXT_TYPE);
77 }
78 
InitFieldDesV11()79 void MmsHeaderCateg::InitFieldDesV11()
80 {
81     /* MMS 1.1 */
82     mmsFieldDesMap_.emplace(MMS_RETRIEVE_STATUS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
83     mmsFieldDesMap_.emplace(MMS_RETRIEVE_TEXT, MmsFieldValueType::MMS_FIELD_ENCODE_TEXT_TYPE);
84     mmsFieldDesMap_.emplace(MMS_READ_STATUS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
85     mmsFieldDesMap_.emplace(MMS_REPLY_CHARGING, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
86     mmsFieldDesMap_.emplace(MMS_REPLY_CHARGING_DEADLINE, MmsFieldValueType::MMS_FIELD_LONG_TYPE);
87     mmsFieldDesMap_.emplace(MMS_REPLY_CHARGING_ID, MmsFieldValueType::MMS_FIELD_TEXT_TYPE);
88     mmsFieldDesMap_.emplace(MMS_REPLY_CHARGING_SIZE, MmsFieldValueType::MMS_FIELD_LONG_TYPE);
89     mmsFieldDesMap_.emplace(MMS_PREVIOUSLY_SENT_BY, MmsFieldValueType::MMS_FIELD_ENCODE_TEXT_TYPE);
90     mmsFieldDesMap_.emplace(MMS_PREVIOUSLY_SENT_DATE, MmsFieldValueType::MMS_FIELD_LONG_TYPE);
91 }
92 
InitFieldDesV12()93 void MmsHeaderCateg::InitFieldDesV12()
94 {
95     /* MMS 1.2 */
96     mmsFieldDesMap_.emplace(MMS_STORE, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
97     mmsFieldDesMap_.emplace(MMS_MM_STATE, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
98     mmsFieldDesMap_.emplace(MMS_MM_FLAGS, MmsFieldValueType::MMS_FIELD_ENCODE_TEXT_TYPE);
99     mmsFieldDesMap_.emplace(MMS_STORE_STATUS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
100     mmsFieldDesMap_.emplace(MMS_STORE_STATUS_TEXT, MmsFieldValueType::MMS_FIELD_ENCODE_TEXT_TYPE);
101     mmsFieldDesMap_.emplace(MMS_STORED, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
102     mmsFieldDesMap_.emplace(MMS_ATTRIBUTES, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
103     mmsFieldDesMap_.emplace(MMS_TOTALS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
104     mmsFieldDesMap_.emplace(MMS_MBOX_TOTALS, MmsFieldValueType::MMS_FIELD_INTEGER_TYPE);
105     mmsFieldDesMap_.emplace(MMS_QUOTAS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
106     mmsFieldDesMap_.emplace(MMS_MBOX_QUOTAS, MmsFieldValueType::MMS_FIELD_INTEGER_TYPE);
107     mmsFieldDesMap_.emplace(MMS_MESSAGE_COUNT, MmsFieldValueType::MMS_FIELD_INTEGER_TYPE);
108     mmsFieldDesMap_.emplace(MMS_CONTENT, MmsFieldValueType::MMS_FIELD_UNKOWN_TYPE);
109     mmsFieldDesMap_.emplace(MMS_START, MmsFieldValueType::MMS_FIELD_INTEGER_TYPE);
110     mmsFieldDesMap_.emplace(MMS_ADDITIONAL_HEADERS, MmsFieldValueType::MMS_FIELD_UNKOWN_TYPE);
111     mmsFieldDesMap_.emplace(MMS_DISTRIBUTION_INDICATOR, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
112     mmsFieldDesMap_.emplace(MMS_ELEMENT_DESCRIPTOR, MmsFieldValueType::MMS_FIELD_UNKOWN_TYPE);
113     mmsFieldDesMap_.emplace(MMS_LIMIT, MmsFieldValueType::MMS_FIELD_INTEGER_TYPE);
114     mmsFieldDesMap_.emplace(MMS_CONTENT_CLASS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE);
115 }
116 
InitSendReqMap()117 void MmsHeaderCateg::InitSendReqMap()
118 {
119     mmsSendReqOptMap_.clear();
120     mmsSendReqOptMap_.emplace(MMS_MESSAGE_TYPE, MmsFieldOptType::MMS_MANDATORY_TYPE);
121     mmsSendReqOptMap_.emplace(MMS_TRANSACTION_ID, MmsFieldOptType::MMS_MANDATORY_TYPE);
122     mmsSendReqOptMap_.emplace(MMS_MMS_VERSION, MmsFieldOptType::MMS_MANDATORY_TYPE);
123     mmsSendReqOptMap_.emplace(MMS_CONTENT_TYPE, MmsFieldOptType::MMS_MANDATORY_TYPE);
124     mmsSendReqOptMap_.emplace(MMS_FROM, MmsFieldOptType::MMS_MANDATORY_TYPE);
125 
126     mmsSendReqOptMap_.emplace(MMS_DATE, MmsFieldOptType::MMS_OPTIONAL_TYPE);
127     mmsSendReqOptMap_.emplace(MMS_TO, MmsFieldOptType::MMS_OPTIONAL_TYPE);
128     mmsSendReqOptMap_.emplace(MMS_CC, MmsFieldOptType::MMS_OPTIONAL_TYPE);
129     mmsSendReqOptMap_.emplace(MMS_BCC, MmsFieldOptType::MMS_OPTIONAL_TYPE);
130     mmsSendReqOptMap_.emplace(MMS_SUBJECT, MmsFieldOptType::MMS_OPTIONAL_TYPE);
131     mmsSendReqOptMap_.emplace(MMS_MESSAGE_CLASS, MmsFieldOptType::MMS_OPTIONAL_TYPE);
132     mmsSendReqOptMap_.emplace(MMS_EXPIRY, MmsFieldOptType::MMS_OPTIONAL_TYPE);
133     mmsSendReqOptMap_.emplace(MMS_PRIORITY, MmsFieldOptType::MMS_OPTIONAL_TYPE);
134     mmsSendReqOptMap_.emplace(MMS_SENDER_VISIBILITY, MmsFieldOptType::MMS_OPTIONAL_TYPE);
135     mmsSendReqOptMap_.emplace(MMS_DELIVERY_REPORT, MmsFieldOptType::MMS_OPTIONAL_TYPE);
136     mmsSendReqOptMap_.emplace(MMS_MESSAGE_TYPE, MmsFieldOptType::MMS_OPTIONAL_TYPE);
137     mmsSendReqOptMap_.emplace(MMS_READ_REPORT, MmsFieldOptType::MMS_OPTIONAL_TYPE);
138 }
139 
InitSendConfMap()140 void MmsHeaderCateg::InitSendConfMap()
141 {
142     mmsSendConfOptMap_.clear();
143 }
144 
CheckIsValueLen(uint8_t fieldId)145 bool MmsHeaderCateg::CheckIsValueLen(uint8_t fieldId)
146 {
147     return false;
148 }
149 
FindFieldDes(uint8_t fieldId)150 MmsFieldValueType MmsHeaderCateg::FindFieldDes(uint8_t fieldId)
151 {
152     auto it = mmsFieldDesMap_.find(fieldId);
153     if (it != mmsFieldDesMap_.end()) {
154         return it->second;
155     }
156     return MmsFieldValueType::MMS_FIELD_UNKOWN_TYPE;
157 }
158 
FindSendReqOptType(uint8_t fieldId)159 MmsFieldOptType MmsHeaderCateg::FindSendReqOptType(uint8_t fieldId)
160 {
161     auto it = mmsSendReqOptMap_.find(fieldId);
162     if (it != mmsSendReqOptMap_.end()) {
163         return it->second;
164     }
165     return MmsFieldOptType::MMS_UNSUPPORTED_TYPE;
166 }
167 
FindSendConfOptType(uint8_t fieldId)168 MmsFieldOptType MmsHeaderCateg::FindSendConfOptType(uint8_t fieldId)
169 {
170     return MmsFieldOptType::MMS_UNSUPPORTED_TYPE;
171 }
172 } // namespace Telephony
173 } // namespace OHOS
174