1 |
|
-module(mod_caps_backend). |
2 |
|
-export([init/2, |
3 |
|
read/2, |
4 |
|
write/3, |
5 |
|
delete_node/2]). |
6 |
|
|
7 |
|
-define(MAIN_MODULE, mod_caps). |
8 |
|
|
9 |
|
%% ---------------------------------------------------------------------- |
10 |
|
%% Callbacks |
11 |
|
%% (exactly the same as specs in this module) |
12 |
|
|
13 |
|
-callback init(HostType, Opts) -> ok when |
14 |
|
HostType :: mongooseim:host_type(), |
15 |
|
Opts :: gen_mod:module_opts(). |
16 |
|
|
17 |
|
-callback read(mongooseim:host_type(), mod_caps:node_pair()) -> |
18 |
|
{ok, mod_caps:maybe_pending_features()} | error. |
19 |
|
|
20 |
|
-callback write(mongooseim:host_type(), mod_caps:node_pair(), |
21 |
|
mod_caps:maybe_pending_features()) -> ok. |
22 |
|
|
23 |
|
-callback delete_node(mongooseim:host_type(), mod_caps:node_pair()) -> ok. |
24 |
|
|
25 |
|
%% ---------------------------------------------------------------------- |
26 |
|
%% API Functions |
27 |
|
|
28 |
|
-spec init(HostType, Opts) -> ok when |
29 |
|
HostType :: mongooseim:host_type(), |
30 |
|
Opts :: gen_mod:module_opts(). |
31 |
|
init(HostType, Opts) -> |
32 |
6 |
TrackedFuns = [], |
33 |
6 |
mongoose_backend:init(HostType, ?MAIN_MODULE, TrackedFuns, Opts), |
34 |
6 |
Args = [HostType, Opts], |
35 |
6 |
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |
36 |
|
|
37 |
|
-spec read(mongooseim:host_type(), mod_caps:node_pair()) -> |
38 |
|
{ok, mod_caps:maybe_pending_features()} | error. |
39 |
|
read(HostType, Node) -> |
40 |
9 |
Args = [HostType, Node], |
41 |
9 |
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |
42 |
|
|
43 |
|
-spec write(mongooseim:host_type(), mod_caps:node_pair(), |
44 |
|
mod_caps:maybe_pending_features()) -> ok. |
45 |
|
write(HostType, Node, Features) -> |
46 |
18 |
Args = [HostType, Node, Features], |
47 |
18 |
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |
48 |
|
|
49 |
|
-spec delete_node(mongooseim:host_type(), mod_caps:node_pair()) -> ok. |
50 |
|
delete_node(HostType, Node) -> |
51 |
:-( |
Args = [HostType, Node], |
52 |
:-( |
mongoose_backend:call_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |