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