struct _atom_ctx
{
AtomError *error;
- gpointer config_data;
+ AtomConfig *config;
AtomBackend *backend;
AtomFrontend *frontend;
GHashTable *bemap;
+ GHashTable *femap;
};
AtomCtx *
AtomCtx *ctx;
ctx = g_slice_new (AtomCtx);
ctx->error = NULL;
- ctx->config_data = NULL;
+ ctx->config = NULL;
ctx->backend = NULL;
ctx->frontend = NULL;
ctx->bemap = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_free);
+ ctx->femap = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, g_free);
return ctx;
}
atom_frontend_delete (ctx->frontend);
if (ctx->bemap)
g_hash_table_destroy (ctx->bemap);
+ if (ctx->femap)
+ g_hash_table_destroy (ctx->femap);
g_slice_free (AtomCtx, ctx);
}
return ctx->error;
}
-void *
-atom_config_data (AtomCtx *ctx)
+AtomConfig *
+atom_config (AtomCtx *ctx)
{
- return ctx->config_data;
+ return ctx->config;
}
void
-atom_config_data_set (AtomCtx *ctx, void *data)
+atom_config_set (AtomCtx *ctx, AtomConfig *config)
{
- ctx->config_data = data;
+ ctx->config = config;
}
AtomBackend *
g_hash_table_replace (ctx->bemap, key, val);
}
}
+
+void
+atom_map_frontend_requests (AtomCtx *ctx, char **reqs,
+ AtomEntry **entries, size_t len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ char *key = g_strdup (reqs[i]);
+ char *val = g_strdup (atom_entry_id (entries[i]));
+ g_hash_table_replace (ctx->femap, key, val);
+ }
+}
+
+AtomID *
+atom_id_new_from_frontend (AtomCtx *ctx, char * req)
+{
+ char *id;
+ if (g_hash_table_lookup_extended (ctx->femap, req, NULL, &id))
+ return atom_id_new (id);
+ return NULL;
+}
+
+char *
+atom_id_to_backend (AtomCtx *ctx, AtomID *id)
+{
+ char *key = atom_id_string (id);
+ char *val;
+ if (g_hash_table_lookup_extended (ctx->bemap, key, NULL, &val))
+ return val;
+ return NULL;
+}