Templates separation between binding API hat and Callbacks
[staging/xdg-launcher.git] / templates / service / binding / xxx-service-hat.h
1 /*
2  * Copyright (C) 2015, 2016 "IoT.bzh"
3  * Author "Fulup Ar Foll"
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef SERVICEHAT_H
18 #define  SERVICEHAT_H
19
20 #define _GNU_SOURCE
21 #include <stdio.h>
22 #include <string.h>
23 #include <json-c/json.h>
24
25 #include <afb/afb-binding.h>
26
27 extern const struct afb_binding_interface *interface;
28
29 struct event
30 {
31         struct event *next;
32         struct afb_event event;
33         char tag[1];
34 };
35
36 /* searchs the event of tag */
37 struct event *event_get(const char *tag);
38
39 /* deletes the event of tag */
40 int event_del(const char *tag);
41
42 /* creates the event of tag */
43 int event_add(const char *tag, const char *name);
44
45 int event_subscribe(struct afb_req request, const char *tag);
46
47 int event_unsubscribe(struct afb_req request, const char *tag);
48
49 int event_push(struct json_object *args, const char *tag);
50
51 void pingSample (struct afb_req request);
52
53 void pingFail (struct afb_req request);
54
55 void pingNull (struct afb_req request);
56
57 void pingBug (struct afb_req request);
58
59 void pingEvent(struct afb_req request);
60
61 // For samples https://linuxprograms.wordpress.com/2010/05/20/json-c-libjson-tutorial/
62 void pingJson (struct afb_req request);
63
64 void subcallcb (void *prequest, int iserror, json_object *object);
65
66 void subcall (struct afb_req request);
67
68 void eventadd (struct afb_req request);
69
70 void eventdel (struct afb_req request);
71
72 void eventsub (struct afb_req request);
73
74 void eventunsub (struct afb_req request);
75
76 void eventpush (struct afb_req request);
77
78 #endif