1 /*
2  * Copyright (C) 2023 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 #include "vcard_website_data.h"
16 
17 #include "telephony_errors.h"
18 
19 namespace OHOS {
20 namespace Telephony {
21 
BuildValuesBucket(OHOS::DataShare::DataShareValuesBucket & valuesBucket)22 int32_t VCardWebsiteData::BuildValuesBucket(OHOS::DataShare::DataShareValuesBucket &valuesBucket)
23 {
24     valuesBucket.Put(ContactData::TYPE_ID, TypeId::WEBSITE);
25     valuesBucket.Put(ContactData::DETAIL_INFO, website_);
26     valuesBucket.Put(ContactData::LABEL_ID, labelId_);
27     valuesBucket.Put(ContactData::LABEL_NAME, labelName_);
28     return TELEPHONY_SUCCESS;
29 }
30 
BuildData(std::shared_ptr<DataShare::DataShareResultSet> resultSet)31 int32_t VCardWebsiteData::BuildData(std::shared_ptr<DataShare::DataShareResultSet> resultSet)
32 {
33     if (resultSet == nullptr) {
34         return TELEPHONY_ERROR;
35     }
36     int32_t index;
37     resultSet->GetColumnIndex(ContactData::DETAIL_INFO, index);
38     resultSet->GetString(index, website_);
39     resultSet->GetColumnIndex(ContactData::LABEL_NAME, index);
40     resultSet->GetString(index, labelName_);
41     resultSet->GetColumnIndex(ContactData::LABEL_ID, index);
42     resultSet->GetString(index, labelId_);
43     return TELEPHONY_SUCCESS;
44 }
45 
InitWebsite(std::string website)46 void VCardWebsiteData::InitWebsite(std::string website)
47 {
48     website_ = website;
49 }
50 
SetWebsite(const std::string & website)51 void VCardWebsiteData::SetWebsite(const std::string &website)
52 {
53     website_ = website;
54 }
55 
GetWebsite()56 std::string VCardWebsiteData::GetWebsite()
57 {
58     return website_;
59 }
60 
SetLabelId(const std::string & labelId)61 void VCardWebsiteData::SetLabelId(const std::string &labelId)
62 {
63     labelId_ = labelId;
64 }
65 
GetLabelId()66 std::string VCardWebsiteData::GetLabelId()
67 {
68     return labelId_;
69 }
70 
SetLabelName(const std::string & labelName)71 void VCardWebsiteData::SetLabelName(const std::string &labelName)
72 {
73     labelName_ = labelName;
74 }
75 
GetLabelName()76 std::string VCardWebsiteData::GetLabelName()
77 {
78     return labelName_;
79 }
80 
81 } // namespace Telephony
82 } // namespace OHOS
83