196279301Sopenharmony_ci/* 296279301Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 396279301Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 496279301Sopenharmony_ci * you may not use this file except in compliance with the License. 596279301Sopenharmony_ci * You may obtain a copy of the License at 696279301Sopenharmony_ci * 796279301Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 896279301Sopenharmony_ci * 996279301Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1096279301Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1196279301Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1296279301Sopenharmony_ci * See the License for the specific language governing permissions and 1396279301Sopenharmony_ci * limitations under the License. 1496279301Sopenharmony_ci */ 1596279301Sopenharmony_ci 1696279301Sopenharmony_ci#ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_CAPSULE_H 1796279301Sopenharmony_ci#define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_CAPSULE_H 1896279301Sopenharmony_ci 1996279301Sopenharmony_ci#include "pixel_map.h" 2096279301Sopenharmony_ci#include "notification_json_convert.h" 2196279301Sopenharmony_ci#include "parcel.h" 2296279301Sopenharmony_ci#include <string> 2396279301Sopenharmony_ci 2496279301Sopenharmony_cinamespace OHOS { 2596279301Sopenharmony_cinamespace Notification { 2696279301Sopenharmony_ciclass NotificationCapsule : public Parcelable, public NotificationJsonConvertionBase { 2796279301Sopenharmony_cipublic: 2896279301Sopenharmony_ci NotificationCapsule() = default; 2996279301Sopenharmony_ci 3096279301Sopenharmony_ci ~NotificationCapsule() = default; 3196279301Sopenharmony_ci 3296279301Sopenharmony_ci /** 3396279301Sopenharmony_ci * @brief Obtains the title of the notification capsule. 3496279301Sopenharmony_ci * 3596279301Sopenharmony_ci * @return Returns the title of the notification capsule. 3696279301Sopenharmony_ci */ 3796279301Sopenharmony_ci std::string GetTitle() const; 3896279301Sopenharmony_ci 3996279301Sopenharmony_ci void SetTitle(const std::string &title); 4096279301Sopenharmony_ci 4196279301Sopenharmony_ci /** 4296279301Sopenharmony_ci * @brief Obtains the icon of the notification capsule. 4396279301Sopenharmony_ci * 4496279301Sopenharmony_ci * @return Returns the icon of the notification capsule. 4596279301Sopenharmony_ci */ 4696279301Sopenharmony_ci const std::shared_ptr<Media::PixelMap> GetIcon() const; 4796279301Sopenharmony_ci 4896279301Sopenharmony_ci void SetIcon(const std::shared_ptr<Media::PixelMap> &icon); 4996279301Sopenharmony_ci 5096279301Sopenharmony_ci /** 5196279301Sopenharmony_ci * @brief Obtains the backgroundcolor of the notification capsule. 5296279301Sopenharmony_ci * 5396279301Sopenharmony_ci * @return Returns the backgroundcolor of the notification capsule. 5496279301Sopenharmony_ci */ 5596279301Sopenharmony_ci std::string GetBackgroundColor() const; 5696279301Sopenharmony_ci 5796279301Sopenharmony_ci void SetBackgroundColor(const std::string &color); 5896279301Sopenharmony_ci 5996279301Sopenharmony_ci /** 6096279301Sopenharmony_ci * @brief Obtains the content of the notification capsule. 6196279301Sopenharmony_ci * 6296279301Sopenharmony_ci * @return Returns the content of the notification capsule. 6396279301Sopenharmony_ci */ 6496279301Sopenharmony_ci std::string GetContent() const; 6596279301Sopenharmony_ci 6696279301Sopenharmony_ci void SetContent(const std::string &content); 6796279301Sopenharmony_ci 6896279301Sopenharmony_ci /** 6996279301Sopenharmony_ci * @brief Returns a string representation of the object. 7096279301Sopenharmony_ci * 7196279301Sopenharmony_ci * @return Returns a string representation of the object. 7296279301Sopenharmony_ci */ 7396279301Sopenharmony_ci std::string Dump(); 7496279301Sopenharmony_ci 7596279301Sopenharmony_ci /** 7696279301Sopenharmony_ci * @brief Converts a notification capsule object into a Json. 7796279301Sopenharmony_ci * 7896279301Sopenharmony_ci * @param jsonObject Indicates the Json object. 7996279301Sopenharmony_ci * @return Returns true if succeed; returns false otherwise. 8096279301Sopenharmony_ci */ 8196279301Sopenharmony_ci bool ToJson(nlohmann::json &jsonObject) const override; 8296279301Sopenharmony_ci 8396279301Sopenharmony_ci /** 8496279301Sopenharmony_ci * @brief Creates a notification capsule object from a Json. 8596279301Sopenharmony_ci * 8696279301Sopenharmony_ci * @param jsonObject Indicates the Json object. 8796279301Sopenharmony_ci * @return Returns the notification capsule. 8896279301Sopenharmony_ci */ 8996279301Sopenharmony_ci static NotificationCapsule *FromJson(const nlohmann::json &jsonObject); 9096279301Sopenharmony_ci 9196279301Sopenharmony_ci /** 9296279301Sopenharmony_ci * @brief Marshal a object into a Parcel. 9396279301Sopenharmony_ci * 9496279301Sopenharmony_ci * @param parcel Indicates the object into the parcel. 9596279301Sopenharmony_ci * @return Returns true if succeed; returns false otherwise. 9696279301Sopenharmony_ci */ 9796279301Sopenharmony_ci virtual bool Marshalling(Parcel &parcel) const override; 9896279301Sopenharmony_ci 9996279301Sopenharmony_ci /** 10096279301Sopenharmony_ci * @brief Unmarshal object from a Parcel. 10196279301Sopenharmony_ci * 10296279301Sopenharmony_ci * @param parcel Indicates the parcel object. 10396279301Sopenharmony_ci * @return Returns the notification capsule. 10496279301Sopenharmony_ci */ 10596279301Sopenharmony_ci static NotificationCapsule *Unmarshalling(Parcel &parcel); 10696279301Sopenharmony_ci 10796279301Sopenharmony_ci void ResetIcon(); 10896279301Sopenharmony_ci 10996279301Sopenharmony_ciprivate: 11096279301Sopenharmony_ci /** 11196279301Sopenharmony_ci * @brief Read a NotificationConversationalMessage object from a Parcel. 11296279301Sopenharmony_ci * 11396279301Sopenharmony_ci * @param parcel Indicates the parcel object. 11496279301Sopenharmony_ci * @return Returns true if succeed; returns false otherwise. 11596279301Sopenharmony_ci */ 11696279301Sopenharmony_ci bool ReadFromParcel(Parcel &parcel); 11796279301Sopenharmony_ci 11896279301Sopenharmony_ciprivate: 11996279301Sopenharmony_ci std::string title_ {}; 12096279301Sopenharmony_ci std::string backgroundColor_ {}; 12196279301Sopenharmony_ci std::string content_ {}; 12296279301Sopenharmony_ci std::shared_ptr<Media::PixelMap> icon_ {}; 12396279301Sopenharmony_ci}; 12496279301Sopenharmony_ci} // namespace Notification 12596279301Sopenharmony_ci} // namespace OHOS 12696279301Sopenharmony_ci 12796279301Sopenharmony_ci#endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_CAPSULE_H 128