gam-resource-manager: adjust to updated proxied call callback signature.
[profile/ivi/murphy.git] / src / core / context.h
1 /*
2  * Copyright (c) 2012, Intel Corporation
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *  * Redistributions of source code must retain the above copyright notice,
9  *    this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *  * Neither the name of Intel Corporation nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #ifndef __MURPHY_CONTEXT_H__
31 #define __MURPHY_CONTEXT_H__
32
33 #include <stdbool.h>
34
35 typedef struct mrp_context_s mrp_context_t;
36
37 #include <murphy/common/list.h>
38 #include <murphy/common/mainloop.h>
39 #include <murphy/resolver/resolver.h>
40
41
42 typedef enum {
43     MRP_STATE_INITIAL = 0,
44     MRP_STATE_LOADING,
45     MRP_STATE_STARTING,
46     MRP_STATE_RUNNING,
47     MRP_STATE_STOPPING
48 } mrp_context_state_t;
49
50
51 struct mrp_context_s {
52     /* logging settings, path configuration, etc. */
53     int         log_mask;                  /* what to log */
54     const char *log_target;                /* and where to log to */
55
56     const char *config_file;               /* configuration file */
57     const char *config_dir;                /* plugin configuration directory */
58     const char *plugin_dir;                /* plugin directory */
59     bool        foreground;                /* whether to stay in foreground*/
60
61     char       *resolver_ruleset;          /* resolver ruleset file */
62
63     const char *blacklist_plugins;         /* blacklisted plugins */
64     const char *blacklist_builtin;         /* blacklisted builtin plugins */
65     const char *blacklist_dynamic;         /* blacklisted dynamic plugins */
66     const char *whitelist_plugins;         /* whitelisted plugins */
67     const char *whitelist_builtin;         /* whitelisted builtin plugins */
68     const char *whitelist_dynamic;         /* whitelisted dynamic plugins */
69     bool        disable_runtime_load;      /* disallow post-startup loading */
70     bool        disable_console;           /* disable murphy console */
71
72     /* actual runtime context data */
73     int              state;                /* context/daemon state */
74     mrp_mainloop_t  *ml;                   /* mainloop */
75     mrp_list_hook_t  plugins;              /* list of loaded plugins */
76     mrp_event_bus_t *plugin_bus;           /* bus for plugin events */
77     mrp_event_bus_t *daemon_bus;           /* bus for daemon events */
78     mrp_list_hook_t  cmd_groups;           /* console command groups */
79     mrp_list_hook_t  consoles;             /* active consoles */
80     mrp_resolver_t  *r;                    /* resolver context */
81     void            *lua_state;            /* state for Lua bindings */
82     mrp_list_hook_t  auth;                 /* authenticator backends */
83
84     /*
85      * Hmm, this is not very nice.  Most of the domain handling code (in
86      * practice all) used to live in the domain-control plugin. To avoid
87      * loading order dependencies on plugin-domain-control we now started
88      * collecting registered handlers of proxied functions here. Calls by
89      * the core to proxied functions of domain controllers and by domain-
90      * controllers to the core are still handled in the domain-control
91      * plugin (and in the domain-controller client library).
92      *
93      * It would be perhaps the cleanest not to have a domain-controller
94      * specific function export mechanism at all. Instead the various
95      * import/export mechanisms (at least plugins, resolver, and this) should
96      * be replaced by / built on a single core implementation that is flexible
97      * enough to handle all the needs of all these.
98      */
99
100     mrp_list_hook_t  domain_methods;       /* functions for domain controllers */
101     void            *domain_invoke;        /* domain invoke handler */
102     void            *domain_data;          /* domain invoke handler data */
103 };
104
105 /** Create a new murphy context. */
106 mrp_context_t *mrp_context_create(void);
107
108 /** Destroy an existing murphy context. */
109 void mrp_context_destroy(mrp_context_t *c);
110
111 /** Set the context state to the given state. */
112 void mrp_context_setstate(mrp_context_t *c, mrp_context_state_t state);
113
114 #endif /* __MURPHY_CONTEXT_H__ */