aboutsummaryrefslogtreecommitdiffstats
path: root/binding/afm-weather-binding.c
diff options
context:
space:
mode:
Diffstat (limited to 'binding/afm-weather-binding.c')
-rw-r--r--binding/afm-weather-binding.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/binding/afm-weather-binding.c b/binding/afm-weather-binding.c
index 4c2418d..d089a71 100644
--- a/binding/afm-weather-binding.c
+++ b/binding/afm-weather-binding.c
@@ -28,7 +28,7 @@
#include <curl/curl.h>
#include <json-c/json.h>
-#define AFB_BINDING_VERSION 2
+#define AFB_BINDING_VERSION 3
#include <afb/afb-binding.h>
#define OPENWEATHER_API_KEY "a860fa437924aec3d0360cc749e25f0e"
@@ -41,7 +41,7 @@ struct {
} data;
static pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;
-static struct afb_event weather_event;
+static afb_event_t weather_event;
// Forward declaration
gboolean update_weather_data(gpointer ptr);
@@ -55,7 +55,7 @@ static void *weather_loop_thread(void *ptr)
return NULL;
}
-static int init()
+static int init(afb_api_t api)
{
pthread_t thread_id;
json_object *response, *query;
@@ -70,7 +70,7 @@ static int init()
query = json_object_new_object();
json_object_object_add(query, "key", json_object_new_string("OPENWEATHERMAP_API_KEY"));
- ret = afb_service_call_sync("persistence", "read", query, &response);
+ ret = afb_service_call_sync("persistence", "read", query, &response, NULL, NULL);
if (ret < 0) {
data.api_key = g_strdup(OPENWEATHER_API_KEY);
@@ -97,7 +97,7 @@ static int init()
query = json_object_new_object();
json_object_object_add(query, "value", json_object_new_string("location"));
- ret = afb_service_call_sync("geoclue", "subscribe", query, &response);
+ ret = afb_service_call_sync("geoclue", "subscribe", query, &response, NULL, NULL);
json_object_put(response);
if (ret < 0) {
@@ -164,7 +164,7 @@ gboolean update_weather_data(gpointer ptr)
return TRUE;
}
-static void onevent(const char *event, struct json_object *object)
+static void onevent(afb_api_t api, const char *event, struct json_object *object)
{
json_object *val = NULL;
double latitude, longitude;
@@ -201,7 +201,7 @@ static void onevent(const char *event, struct json_object *object)
update_weather_data(NULL);
}
-static void current_weather(struct afb_req request)
+static void current_weather(afb_req_t request)
{
json_object *jresp = NULL;
@@ -232,7 +232,7 @@ static int validate_key(const char *value)
return 0;
}
-static void api_key(struct afb_req request)
+static void api_key(afb_req_t request)
{
const char *value = afb_req_value(request, "value");
json_object *jresp = NULL;
@@ -254,7 +254,7 @@ static void api_key(struct afb_req request)
json_object_object_add(jresp, "key", json_object_new_string("OPENWEATHERMAP_API_KEY"));
json_object_object_add(jresp, "value", json_object_new_string(value));
- ret = afb_service_call_sync("persistence", "update", jresp, NULL);
+ ret = afb_service_call_sync("persistence", "update", jresp, NULL, NULL, NULL);
if (ret < 0) {
afb_req_fail(request, "failed", "Couldn't store API key");
return;
@@ -268,7 +268,7 @@ static void api_key(struct afb_req request)
afb_req_success(request, jresp, NULL);
}
-static void subscribe(struct afb_req request)
+static void subscribe(afb_req_t request)
{
const char *value = afb_req_value(request, "value");
@@ -289,7 +289,7 @@ static void subscribe(struct afb_req request)
afb_req_fail(request, "failed", "Invalid event");
}
-static void unsubscribe(struct afb_req request)
+static void unsubscribe(afb_req_t request)
{
const char *value = afb_req_value(request, "value");
@@ -302,7 +302,7 @@ static void unsubscribe(struct afb_req request)
afb_req_fail(request, "failed", "Invalid event");
}
-static const struct afb_verb_v2 binding_verbs[] = {
+static const struct afb_verb_v3 binding_verbs[] = {
{ .verb = "current_weather", .callback = current_weather, .info = "Current weather data" },
{ .verb = "api_key", .callback = api_key, .info = "Get/set OpenWeatherMap API key" },
{ .verb = "subscribe", .callback = subscribe, .info = "Subscribe to weather events" },
@@ -313,7 +313,7 @@ static const struct afb_verb_v2 binding_verbs[] = {
/*
* binder API description
*/
-const struct afb_binding_v2 afbBindingV2 = {
+const struct afb_binding_v3 afbBindingV3 = {
.api = "weather",
.specification = "Weather service API",
.verbs = binding_verbs,