• 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_address.h"
17 
18 #include <glib.h>
19 
20 #include "utils/mms_charset.h"
21 #include "mms_charset.h"
22 
23 namespace OHOS {
24 namespace Telephony {
MmsAddress(const std::string addressString,MmsCharSets charset)25 MmsAddress::MmsAddress(const std::string addressString, MmsCharSets charset)
26     : addressString_(addressString), charset_(charset)
27 {
28     CheckAddressType();
29 }
30 
MmsAddress()31 MmsAddress::MmsAddress() {}
32 
~MmsAddress()33 MmsAddress::~MmsAddress() {}
34 
SetMmsAddressString(const std::string addressString,MmsCharSets charset)35 void MmsAddress::SetMmsAddressString(const std::string addressString, MmsCharSets charset)
36 {
37     addressString_ = addressString;
38     charset_ = charset;
39     CheckAddressType();
40 }
41 
GetAddressString()42 std::string MmsAddress::GetAddressString()
43 {
44     return addressString_;
45 }
46 
GetAddressCharset()47 MmsCharSets MmsAddress::GetAddressCharset()
48 {
49     return charset_;
50 }
51 
GetAddressType()52 MmsAddress::MmsAddressType MmsAddress::GetAddressType()
53 {
54     return addressType_;
55 }
56 
CheckAddressType()57 void MmsAddress::CheckAddressType()
58 {
59     if (addressString_.find("PLMN")) {
60         addressType_ = ADDRESS_TYPE_PLMN;
61     } else if (addressString_.find("IPv4")) {
62         addressType_ = ADDRESS_TYPE_PLMN;
63     } else if (addressString_.find("IPv6")) {
64         addressType_ = ADDRESS_TYPE_PLMN;
65     } else if (addressString_.find("EMAIL")) {
66         addressType_ = ADDRESS_TYPE_PLMN;
67     } else {
68         addressType_ = ADDRESS_TYPE_UNKNOWN;
69     }
70 }
71 } // namespace Telephony
72 } // namespace OHOS
73