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_nickname_data.h" 16 17 #include "telephony_errors.h" 18 19 namespace OHOS { 20 namespace Telephony { 21 BuildValuesBucket(OHOS::DataShare::DataShareValuesBucket & valuesBucket)22int32_t VCardNicknameData::BuildValuesBucket(OHOS::DataShare::DataShareValuesBucket &valuesBucket) 23 { 24 valuesBucket.Put(ContactData::TYPE_ID, TypeId::NICKNAME); 25 valuesBucket.Put(ContactData::DETAIL_INFO, nickname_); 26 return TELEPHONY_SUCCESS; 27 } 28 BuildData(std::shared_ptr<DataShare::DataShareResultSet> resultSet)29int32_t VCardNicknameData::BuildData(std::shared_ptr<DataShare::DataShareResultSet> resultSet) 30 { 31 if (resultSet == nullptr) { 32 return TELEPHONY_ERROR; 33 } 34 int32_t index; 35 resultSet->GetColumnIndex(ContactData::DETAIL_INFO, index); 36 resultSet->GetString(index, nickname_); 37 return TELEPHONY_SUCCESS; 38 } 39 SetNickName(const std::string & nickname)40void VCardNicknameData::SetNickName(const std::string &nickname) 41 { 42 nickname_ = nickname; 43 } 44 GetNickName()45std::string VCardNicknameData::GetNickName() 46 { 47 return nickname_; 48 } 49 50 } // namespace Telephony 51 } // namespace OHOS 52