Little code cleaning. 73/19473/1
authorRomain Forlot <romain.forlot@iot.bzh>
Fri, 4 Jan 2019 13:24:11 +0000 (14:24 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Fri, 4 Jan 2019 13:37:24 +0000 (14:37 +0100)
Rename apiHandle to api.
Add a missing parameter to QAfbWebsocketClient::call function
comment.

Change-Id: I6fb1acd7357fbea3132cd429e9477a1a0b8a4f43
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
afb-timer.c
afb-timer.h
curl-wrap.h
filescan-utils.h
qafbwebsocketclient.cpp

index 30ab80d..b302278 100644 (file)
@@ -66,32 +66,23 @@ void TimerEvtStop(TimerHandleT *timerHandle) {
     free (timerHandle);
 }
 
-
-void TimerEvtStart(afb_api_t apiHandle, TimerHandleT *timerHandle, timerCallbackT callback, void *context) {
+void TimerEvtStart(afb_api_t api, TimerHandleT *timerHandle, timerCallbackT callback, void *context) {
     uint64_t usec;
 
     // populate CB handle
     timerHandle->callback=callback;
     timerHandle->context=context;
-    timerHandle->api=apiHandle;
+    timerHandle->api=api;
 
     // set a timer with ~250us accuracy
-    sd_event_now(afb_api_get_event_loop(apiHandle), CLOCK_MONOTONIC, &usec);
-    sd_event_add_time(afb_api_get_event_loop(apiHandle), &timerHandle->evtSource, CLOCK_MONOTONIC, usec+timerHandle->delay*1000, 250, TimerNext, timerHandle);
-}
-
-
-// Create Binding Event at Init
-int TimerEvtInit (afb_api_t apiHandle) {
-
-    AFB_API_DEBUG (apiHandle, "Timer-Init Done");
-    return 0;
+    sd_event_now(afb_api_get_event_loop(api), CLOCK_MONOTONIC, &usec);
+    sd_event_add_time(afb_api_get_event_loop(api), &timerHandle->evtSource, CLOCK_MONOTONIC, usec+timerHandle->delay*1000, 250, TimerNext, timerHandle);
 }
 
-uint64_t LockWait(afb_api_t apiHandle, uint64_t utimeout) {
+uint64_t LockWait(afb_api_t api, uint64_t utimeout) {
     uint64_t current_usec, pre_usec;
 
-    struct sd_event *event = afb_api_get_event_loop(apiHandle);
+    struct sd_event *event = afb_api_get_event_loop(api);
 
     sd_event_now(event, CLOCK_MONOTONIC, &pre_usec);
     sd_event_run(event, utimeout);
index 5050436..1d1ebb7 100644 (file)
@@ -30,7 +30,6 @@ extern "C" {
 // ----------------------
 
 typedef struct TimerHandleS {
-    int magic;
     int count;
     int delay;
     const char*uid;
@@ -43,11 +42,10 @@ typedef struct TimerHandleS {
 
 typedef int (*timerCallbackT)(TimerHandleT *context);
 
-extern int TimerEvtInit (afb_api_t apiHandle);
-extern void TimerEvtStart(afb_api_t apiHandle, TimerHandleT *timerHandle, timerCallbackT callback, void *context);
+extern void TimerEvtStart(afb_api_t api, TimerHandleT *timerHandle, timerCallbackT callback, void *context);
 extern void TimerEvtStop(TimerHandleT *timerHandle);
 
-extern uint64_t LockWait(afb_api_t apiHandle, uint64_t utimeout);
+extern uint64_t LockWait(afb_api_t api, uint64_t utimeout);
 #ifdef __cplusplus
 }
 #endif
index ab91bca..26fe210 100644 (file)
@@ -20,9 +20,6 @@
 
 #include <curl/curl.h>
 
-extern char *curl_wrap_url (const char *base, const char *path,
-                            const char *const *query, size_t * size);
-
 extern int curl_wrap_perform (CURL * curl, char **result, size_t * size);
 
 extern void curl_wrap_do(CURL *curl, void (*callback)(void *closure, int status, CURL *curl, const char *result, size_t size), void *closure);
index a74dcb3..d6c645f 100644 (file)
@@ -95,12 +95,12 @@ static inline char *GetBindingDirPath_v2()
 __attribute__((alias("GetBindingDirPath_v2")))
 static char *GetBindingDirPath();
 #else
-static char *GetBindingDirPath_v3(struct afb_api_x3* apiHandle)
+static char *GetBindingDirPath_v3(struct afb_api_x3* api)
 {
-    return GetBindingDirPath_(afb_api_x3_rootdir_get_fd(apiHandle));
+    return GetBindingDirPath_(afb_api_x3_rootdir_get_fd(api));
 }
 __attribute__((alias("GetBindingDirPath_v3")))
-static char *GetBindingDirPath(struct afb_api_x3* apiHandle);
+static char *GetBindingDirPath(struct afb_api_x3* api);
 #endif
 
 /**
index f0f3dce..0cbc274 100644 (file)
@@ -81,6 +81,7 @@ void QAfbWebsocketClient::close()
  * \param api Api to call.
  * \param verb Verb to call.
  * \param arg Argument to pass.
+ * \param closure callback to call at the verb reply
  */
 void QAfbWebsocketClient::call(const QString& api, const QString& verb, const QJsonValue& arg, closure_t closure)
 {