X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fhs-appinfo.h;fp=src%2Fhs-appinfo.h;h=7747f52320c5cb594e9f9f28108b26f1f3aba97c;hb=211769e800f3a57de55b3774de82af55d2a0160a;hp=0000000000000000000000000000000000000000;hpb=25299ef60fa4df5f590ff364cff004e90376a4bf;p=apps%2Fagl-service-homescreen.git diff --git a/src/hs-appinfo.h b/src/hs-appinfo.h new file mode 100644 index 0000000..7747f52 --- /dev/null +++ b/src/hs-appinfo.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2019 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HOMESCREEN_APPINFO_H +#define HOMESCREEN_APPINFO_H + +#include +#include +#include +#include +#include +#include +#include "hs-helper.h" +#include "hs-proxy.h" + + +struct AppDetail { + std::string name; + std::string id; + std::string detail; // detail json_object string + bool periphery; + + std::string getProperty(std::string key) const; +}; + +class HS_AppInfo { +public: + HS_AppInfo() = default; + ~HS_AppInfo(); + HS_AppInfo(HS_AppInfo const &) = delete; + HS_AppInfo &operator=(HS_AppInfo const &) = delete; + HS_AppInfo(HS_AppInfo &&) = delete; + HS_AppInfo &operator=(HS_AppInfo &&) = delete; + + static HS_AppInfo* instance(void); + int init(afb_api_t api); + void onEvent(afb_api_t api, const char *event, struct json_object *object); + + void getRunnables(struct json_object **object); + std::string getAppProperty(const std::string appid, std::string key) const; + std::string checkAppId(const std::string &appid); + +private: + void updateAppDetailList(afb_api_t api, struct json_object *object); + void createAppDetailList(struct json_object *object); + std::string parseAppDetail(struct json_object *object, AppDetail &info) const; + void addAppDetail(struct json_object *object); + void removeAppDetail(std::string appid); + struct json_object* retrieveRunnables(struct json_object *obj_runnables, std::string id); + void pushAppListChangedEvent(const char *oper, struct json_object *object); + std::string id2appid(const std::string &id) const; + bool isPeripheryApp(const char *appid) const; + + // applications can't display on launcher + const std::vector periphery_app_list { + "launcher", + "homescreen", + "onscreenapp", + "restriction" + }; + + typedef void (HS_AppInfo::*func_handler)(afb_api_t, struct json_object*); + const std::unordered_map concerned_event_list { + {"afm-main/application-list-changed", &HS_AppInfo::updateAppDetailList} + }; + +private: + static HS_AppInfo* me; + HS_AfmMainProxy* afmmain = nullptr; + std::unordered_map appid2name; + std::unordered_map name2appid; + std::unordered_map app_detail_list; + std::mutex mtx; +}; + +#endif // HOMESCREEN_APPINFO_H \ No newline at end of file