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
Introduce subcontext for subcalls
[src/app-framework-binder.git]
/
src
/
afb-context.c
diff --git
a/src/afb-context.c
b/src/afb-context.c
index
eec4ebb
..
174ac16
100644
(file)
--- a/
src/afb-context.c
+++ b/
src/afb-context.c
@@
-31,7
+31,8
@@
static void init_context(struct afb_context *context, struct afb_session *sessio
/* reset the context for the session */
context->session = session;
context->flags = 0;
/* reset the context for the session */
context->session = session;
context->flags = 0;
- context->api_index = -1;
+ context->super = NULL;
+ context->api_key = NULL;
context->loa_in = afb_session_get_LOA(session) & 7;
/* check the token */
context->loa_in = afb_session_get_LOA(session) & 7;
/* check the token */
@@
-48,6
+49,12
@@
void afb_context_init(struct afb_context *context, struct afb_session *session,
init_context(context, afb_session_addref(session), token);
}
init_context(context, afb_session_addref(session), token);
}
+void afb_context_subinit(struct afb_context *context, struct afb_context *super)
+{
+ *context = *super;
+ context->super = super;
+}
+
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;
@@
-66,7
+73,7
@@
int afb_context_connect(struct afb_context *context, const char *uuid, const cha
void afb_context_disconnect(struct afb_context *context)
{
void afb_context_disconnect(struct afb_context *context)
{
- if (context->session
!= NULL
) {
+ if (context->session
&& !context->super
) {
if (context->refreshing && !context->refreshed) {
afb_session_new_token (context->session);
context->refreshed = 1;
if (context->refreshing && !context->refreshed) {
afb_session_new_token (context->session);
context->refreshed = 1;
@@
-86,7
+93,7
@@
void afb_context_disconnect(struct afb_context *context)
const char *afb_context_sent_token(struct afb_context *context)
{
const char *afb_context_sent_token(struct afb_context *context)
{
- if (context->session == NULL || context->closing)
+ if (context->session == NULL || context->closing
|| context->super
)
return NULL;
if (!context->refreshing)
return NULL;
return NULL;
if (!context->refreshing)
return NULL;
@@
-99,7
+106,7
@@
const char *afb_context_sent_token(struct afb_context *context)
const char *afb_context_sent_uuid(struct afb_context *context)
{
const char *afb_context_sent_uuid(struct afb_context *context)
{
- if (context->session == NULL || context->closing)
+ if (context->session == NULL || context->closing
|| context->super
)
return NULL;
if (!context->created)
return NULL;
return NULL;
if (!context->created)
return NULL;
@@
-109,38
+116,54
@@
const char *afb_context_sent_uuid(struct afb_context *context)
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 afb_session_get_
value(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 afb_session_set_value(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)
{
- context->closing = 1;
+ if (context->super)
+ afb_context_close(context->super);
+ else
+ context->closing = 1;
}
void afb_context_refresh(struct afb_context *context)
{
}
void afb_context_refresh(struct afb_context *context)
{
- assert(context->validated);
- context->refreshing = 1;
+ if (context->super)
+ afb_context_refresh(context->super);
+ else {
+ assert(context->validated);
+ context->refreshing = 1;
+ }
}
int afb_context_check(struct afb_context *context)
{
}
int afb_context_check(struct afb_context *context)
{
+ if (context->super)
+ return afb_context_check(context);
return context->validated;
}
int afb_context_check_loa(struct afb_context *context, unsigned loa)
{
return context->validated;
}
int afb_context_check_loa(struct afb_context *context, unsigned loa)
{
+ if (context->super)
+ return afb_context_check_loa(context->super, loa);
return context->loa_in >= loa;
}
int afb_context_change_loa(struct afb_context *context, unsigned loa)
{
return context->loa_in >= loa;
}
int afb_context_change_loa(struct afb_context *context, unsigned loa)
{
+ if (context->super)
+ return afb_context_change_loa(context, loa);
+
if (!context->validated || loa > 7)
return 0;
if (!context->validated || loa > 7)
return 0;