modify
[apps/agl-service-homescreen.git] / src / hs-helper.h
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef HOMESCREEN_HELPER_H
18 #define HOMESCREEN_HELPER_H
19 #define AFB_BINDING_VERSION 3
20 #include <afb/afb-binding>
21 #include <json-c/json.h>
22 #include <string>
23
24 #define AFB_EVENT_BAD_REQUEST                 100
25 #define AFB_REQ_SUBSCRIBE_ERROR               101
26 #define AFB_REQ_UNSUBSCRIBE_ERROR             102
27 #define AFB_REQ_SHOWNOTIFICATION_ERROR        103
28 #define AFB_REQ_SHOWINFORMATION_ERROR         104
29 #define AFB_REQ_GETAPPLICATIONID_ERROR        105
30 #define AFB_REQ_NOT_STARTED_APPLICATION       106
31
32 typedef enum REQ_ERROR
33 {
34   REQ_FAIL = -1,
35   REQ_OK=0,
36   NOT_NUMBER,
37   OUT_RANGE
38 }REQ_ERROR;
39
40 extern const char* evlist[];
41 extern const char _error[];
42 extern const char _application_id[];
43 extern const char _display_message[];
44 extern const char _reply_message[];
45 extern const char _keyData[];
46 extern const char _keyId[];
47
48 REQ_ERROR get_value_uint16(const afb_req_t request, const char *source, uint16_t *out_id);
49 REQ_ERROR get_value_int16(const afb_req_t request, const char *source, int16_t *out_id);
50 REQ_ERROR get_value_int32(const afb_req_t request, const char *source, int32_t *out_id);
51 void hs_add_object_to_json_object(struct json_object* j_obj, int count, ...);
52 void hs_add_object_to_json_object_str(struct json_object* j_obj, int count, ...);
53 void hs_add_object_to_json_object_func(struct json_object* j_obj, const char* verb_name, int count, ...);
54 int hs_search_event_name_index(const char* value);
55 std::string get_application_id(const afb_req_t request);
56 int readJsonFile(const char* file, struct json_object **obj);
57 int writeJsonFile(const char* file,  struct json_object *obj);
58
59 typedef int (*event_hook_func)(afb_api_t api, const char *event, struct json_object *object);
60 void setEventHook(const char *event, const event_hook_func f);
61
62 #endif /*HOMESCREEN_HELPER_H*/