Code Review
/
src
/
app-framework-binder.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Use xreq for services
[src/app-framework-binder.git]
/
src
/
afb-context.c
diff --git
a/src/afb-context.c
b/src/afb-context.c
index
5fe3276
..
6eb29f0
100644
(file)
--- a/
src/afb-context.c
+++ b/
src/afb-context.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 2015, 2016 "IoT.bzh"
+ * Copyright (C) 2015, 2016
, 2017
"IoT.bzh"
* Author "Fulup Ar Foll"
* Author José Bollo <jose.bollo@iot.bzh>
*
* Author "Fulup Ar Foll"
* Author José Bollo <jose.bollo@iot.bzh>
*
@@
-21,39
+21,39
@@
#include <assert.h>
#include <stdlib.h>
#include <assert.h>
#include <stdlib.h>
-#include "session.h"
+#include "
afb-
session.h"
#include "afb-context.h"
#include "afb-context.h"
-static void init_context(struct afb_context *context, struct
AFB_clientCtx
*session, const char *token)
+static void init_context(struct afb_context *context, struct
afb_session
*session, const char *token)
{
assert(session != NULL);
/* reset the context for the session */
context->session = session;
context->flags = 0;
{
assert(session != NULL);
/* reset the context for the session */
context->session = session;
context->flags = 0;
- context->api_
index = -1
;
- context->loa_in =
ctxClientGet
LOA(session) & 7;
+ context->api_
key = NULL
;
+ context->loa_in =
afb_session_get_
LOA(session) & 7;
/* check the token */
if (token != NULL) {
/* check the token */
if (token != NULL) {
- if (
ctxTokenCheck
(session, token))
+ if (
afb_session_check_token
(session, token))
context->validated = 1;
else
context->invalidated = 1;
}
}
context->validated = 1;
else
context->invalidated = 1;
}
}
-void afb_context_init(struct afb_context *context, struct
AFB_clientCtx
*session, const char *token)
+void afb_context_init(struct afb_context *context, struct
afb_session
*session, const char *token)
{
{
- init_context(context,
ctxClientAddR
ef(session), token);
+ init_context(context,
afb_session_addr
ef(session), token);
}
int afb_context_connect(struct afb_context *context, const char *uuid, const char *token)
{
int created;
}
int afb_context_connect(struct afb_context *context, const char *uuid, const char *token)
{
int created;
- struct
AFB_clientCtx
*session;
+ struct
afb_session
*session;
- session =
ctxClientGetSession
(uuid, &created);
+ session =
afb_session_get
(uuid, &created);
if (session == NULL)
return -1;
init_context(context, session, token);
if (session == NULL)
return -1;
init_context(context, session, token);
@@
-68,18
+68,18
@@
void afb_context_disconnect(struct afb_context *context)
{
if (context->session != NULL) {
if (context->refreshing && !context->refreshed) {
{
if (context->session != NULL) {
if (context->refreshing && !context->refreshed) {
-
ctxTokenNew
(context->session);
+
afb_session_new_token
(context->session);
context->refreshed = 1;
}
if (context->loa_changing && !context->loa_changed) {
context->refreshed = 1;
}
if (context->loa_changing && !context->loa_changed) {
-
ctxClientSet
LOA (context->session, context->loa_out);
+
afb_session_set_
LOA (context->session, context->loa_out);
context->loa_changed = 1;
}
if (context->closing && !context->closed) {
context->loa_changed = 1;
}
if (context->closing && !context->closed) {
-
ctxClientC
lose(context->session);
+
afb_session_c
lose(context->session);
context->closed = 1;
}
context->closed = 1;
}
-
ctxClientU
nref(context->session);
+
afb_session_u
nref(context->session);
context->session = NULL;
}
}
context->session = NULL;
}
}
@@
-91,10
+91,10
@@
const char *afb_context_sent_token(struct afb_context *context)
if (!context->refreshing)
return NULL;
if (!context->refreshed) {
if (!context->refreshing)
return NULL;
if (!context->refreshed) {
-
ctxTokenNew
(context->session);
+
afb_session_new_token
(context->session);
context->refreshed = 1;
}
context->refreshed = 1;
}
- return
ctxClientGetT
oken(context->session);
+ return
afb_session_t
oken(context->session);
}
const char *afb_context_sent_uuid(struct afb_context *context)
}
const char *afb_context_sent_uuid(struct afb_context *context)
@@
-103,19
+103,21
@@
const char *afb_context_sent_uuid(struct afb_context *context)
return NULL;
if (!context->created)
return NULL;
return NULL;
if (!context->created)
return NULL;
- return
ctxClientGetU
uid(context->session);
+ return
afb_session_u
uid(context->session);
}
void *afb_context_get(struct afb_context *context)
{
assert(context->session != NULL);
}
void *afb_context_get(struct afb_context *context)
{
assert(context->session != NULL);
- return
ctxClientValueGet(context->session, context->api_index
);
+ return
afb_session_get_cookie(context->session, context->api_key
);
}
void afb_context_set(struct afb_context *context, void *value, void (*free_value)(void*))
{
}
void afb_context_set(struct afb_context *context, void *value, void (*free_value)(void*))
{
+ int rc;
assert(context->session != NULL);
assert(context->session != NULL);
- return ctxClientValueSet(context->session, context->api_index, value, free_value);
+ rc = afb_session_set_cookie(context->session, context->api_key, value, free_value);
+ (void)rc; /* TODO */
}
void afb_context_close(struct afb_context *context)
}
void afb_context_close(struct afb_context *context)