1 /* 2 * Copyright (c) 2021 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 16 #include "app_account_subscribe_info.h" 17 18 #include "account_log_wrapper.h" 19 20 namespace OHOS { 21 namespace AccountSA { AppAccountSubscribeInfo()22AppAccountSubscribeInfo::AppAccountSubscribeInfo() 23 {} 24 AppAccountSubscribeInfo(std::vector<std::string> & owners)25AppAccountSubscribeInfo::AppAccountSubscribeInfo(std::vector<std::string> &owners) : owners_(owners) 26 {} 27 GetOwners(std::vector<std::string> & owners) const28ErrCode AppAccountSubscribeInfo::GetOwners(std::vector<std::string> &owners) const 29 { 30 owners = owners_; 31 32 return ERR_OK; 33 } 34 SetOwners(const std::vector<std::string> & owners)35ErrCode AppAccountSubscribeInfo::SetOwners(const std::vector<std::string> &owners) 36 { 37 owners_ = owners; 38 39 return ERR_OK; 40 } 41 Marshalling(Parcel & parcel) const42bool AppAccountSubscribeInfo::Marshalling(Parcel &parcel) const 43 { 44 if (!parcel.WriteStringVector(owners_)) { 45 ACCOUNT_LOGE("failed to write string vector owners_"); 46 return false; 47 } 48 49 return true; 50 } 51 Unmarshalling(Parcel & parcel)52AppAccountSubscribeInfo *AppAccountSubscribeInfo::Unmarshalling(Parcel &parcel) 53 { 54 AppAccountSubscribeInfo *subscribeInfo = new (std::nothrow) AppAccountSubscribeInfo(); 55 56 if (subscribeInfo && !subscribeInfo->ReadFromParcel(parcel)) { 57 ACCOUNT_LOGE("failed to read from parcel"); 58 delete subscribeInfo; 59 subscribeInfo = nullptr; 60 } 61 62 return subscribeInfo; 63 } 64 ReadFromParcel(Parcel & parcel)65bool AppAccountSubscribeInfo::ReadFromParcel(Parcel &parcel) 66 { 67 if (!parcel.ReadStringVector(&owners_)) { 68 ACCOUNT_LOGE("failed to read string vector owners_"); 69 return false; 70 } 71 72 return true; 73 } 74 } // namespace AccountSA 75 } // namespace OHOS 76