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_im_data.h"
16
17 #include "telephony_errors.h"
18
19 namespace OHOS {
20 namespace Telephony {
21
BuildValuesBucket(OHOS::DataShare::DataShareValuesBucket & valuesBucket)22 int32_t VCardImData::BuildValuesBucket(OHOS::DataShare::DataShareValuesBucket &valuesBucket)
23 {
24 valuesBucket.Put(ContactData::TYPE_ID, TypeId::IM);
25 valuesBucket.Put(ContactData::DETAIL_INFO, address_);
26 valuesBucket.Put(ContactData::LABEL_ID, labelId_);
27 return TELEPHONY_SUCCESS;
28 }
29
BuildData(std::shared_ptr<DataShare::DataShareResultSet> resultSet)30 int32_t VCardImData::BuildData(std::shared_ptr<DataShare::DataShareResultSet> resultSet)
31 {
32 if (resultSet == nullptr) {
33 return TELEPHONY_ERROR;
34 }
35 int32_t index;
36 resultSet->GetColumnIndex(ContactData::DETAIL_INFO, index);
37 resultSet->GetString(index, address_);
38 resultSet->GetColumnIndex(ContactData::LABEL_ID, index);
39 resultSet->GetString(index, labelId_);
40 return TELEPHONY_SUCCESS;
41 }
42
SetAddress(const std::string & address)43 void VCardImData::SetAddress(const std::string &address)
44 {
45 address_ = address;
46 }
47
GetAddress()48 std::string VCardImData::GetAddress()
49 {
50 return address_;
51 }
52
SetLabelId(const std::string & labelId)53 void VCardImData::SetLabelId(const std::string &labelId)
54 {
55 labelId_ = labelId;
56 }
57
GetLabelId()58 std::string VCardImData::GetLabelId()
59 {
60 return labelId_;
61 }
62
63 } // namespace Telephony
64 } // namespace OHOS
65