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_relation_data.h"
16
17 #include "telephony_errors.h"
18
19 namespace OHOS {
20 namespace Telephony {
21
BuildValuesBucket(OHOS::DataShare::DataShareValuesBucket & valuesBucket)22 int32_t VCardRelationData::BuildValuesBucket(OHOS::DataShare::DataShareValuesBucket &valuesBucket)
23 {
24 valuesBucket.Put(ContactData::TYPE_ID, TypeId::RELATION);
25 valuesBucket.Put(ContactData::LABEL_ID, labelId_);
26 valuesBucket.Put(ContactData::LABEL_NAME, labelName_);
27 valuesBucket.Put(ContactData::DETAIL_INFO, relationName_);
28 return TELEPHONY_SUCCESS;
29 }
30
BuildData(std::shared_ptr<DataShare::DataShareResultSet> resultSet)31 int32_t VCardRelationData::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, relationName_);
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
SetRelationName(const std::string & name)46 void VCardRelationData::SetRelationName(const std::string &name)
47 {
48 relationName_ = name;
49 }
50
GetRelationName()51 std::string VCardRelationData::GetRelationName()
52 {
53 return relationName_;
54 }
55
SetLabelId(const std::string & id)56 void VCardRelationData::SetLabelId(const std::string &id)
57 {
58 labelId_ = id;
59 }
60
GetLabelId()61 std::string VCardRelationData::GetLabelId()
62 {
63 return labelId_;
64 }
65
SetLabelName(const std::string & name)66 void VCardRelationData::SetLabelName(const std::string &name)
67 {
68 labelName_ = name;
69 }
70
GetLabelName()71 std::string VCardRelationData::GetLabelName()
72 {
73 return labelName_;
74 }
75
76 } // namespace Telephony
77 } // namespace OHOS
78