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