PageRenderTime 74ms CodeModel.GetById 40ms app.highlight 16ms RepoModel.GetById 14ms app.codeStats 0ms

/ucengine/include/uce.hrl

http://github.com/AF83/ucengine
Erlang | 181 lines | 129 code | 24 blank | 28 comment | 0 complexity | 8e04f581a512124df73b833983601283 MD5 | raw file
  1-record(uce_event, {
  2          %% eventid
  3          id = none,
  4          %% date (ms from epoch)
  5          datetime = undefined,
  6          %% location = [Meeting]
  7          location = "",
  8          %% From: uid|brick
  9          from,
 10          %% To : string
 11          to = "",
 12          %% Type event : string
 13          type,
 14          %% parent id
 15          parent = "",
 16          %% MetaData : list
 17          metadata = {struct, []}}).
 18
 19-record(uce_presence, {
 20          %% presenceid
 21          id = none,
 22          %% user id
 23          user,
 24          %% authentication method
 25          auth,
 26          %% session timeout
 27          timeout = 0,
 28          %% last ping
 29          last_activity = 0,
 30          %% list meetings joined by user
 31          meetings = [],
 32          %% nb streams open
 33          streams = 0}).
 34
 35-record(uce_meeting, {
 36          %% uce meeting id
 37          id = none,
 38          roster = [],
 39          %% [{"description",Desc}, {"language",Lang}, ... ]
 40          metadata = {struct, []}}).
 41
 42-record(uce_file, {
 43          % fileid
 44          id = none,
 45          % name
 46          name,
 47          % Meeting
 48          location = "",
 49          % path
 50          uri = [],
 51          %% date (ms from epoch)
 52          datetime = undefined,
 53          % mime type
 54          mime = "text/plain",
 55          % name as send by the browser
 56          metadata = {struct, []}
 57         }).
 58
 59-record(uce_user, {
 60          %% User uid
 61          id = none,
 62          %% name
 63          name,
 64          auth,
 65          credential = "",
 66          metadata = {struct, []},
 67          roles=[]}).
 68
 69-record(uce_role, {
 70          id = "",
 71          acl=[]}).
 72
 73-record(uce_access, {
 74          action,
 75          object,
 76          conditions=[]}).
 77
 78-record(uce_route, {
 79          method,
 80          path,
 81          content_type = any,
 82          callback}).
 83
 84-record(file_upload, {
 85          fd,
 86          filename,
 87          uri}).
 88
 89% Types
 90-type domain()         :: string().
 91-type meeting_id()     :: string().
 92-type meeting()        :: #uce_meeting{}.
 93-type event_id()       :: string().
 94-type event()          :: #uce_event{}.
 95-type user()           :: #uce_user{}.
 96-type presence()       :: #uce_presence{}.
 97-type sid()            :: string().
 98-type uid()            :: string().
 99-type role_id()        :: string().
100-type role()           :: #uce_role{}.
101-type access()         :: #uce_access{}.
102-type route()          :: #uce_route{}.
103-type timestamp()      :: integer().
104
105
106-define(VERSION, "0.6").
107
108-define(SESSION_TIMEOUT, (config:get(presence_timeout) * 1000)).
109
110-define(DEBUG(Format, Args),
111        uce_log:debug(Format, [?MODULE, ?LINE], Args)).
112
113-define(INFO_MSG(Format, Args),
114        uce_log:info(Format, [?MODULE, ?LINE], Args)).
115
116-define(WARNING_MSG(Format, Args),
117        uce_log:warning(Format, [?MODULE, ?LINE], Args)).
118
119-define(ERROR_MSG(Format, Args),
120        uce_log:error(Format, [?MODULE, ?LINE], Args)).
121
122-define(CRITICAL_MSG(Format, Args),
123        uce_log:critical(Format, [?MODULE, ?LINE], Args)).
124
125-define(COUNTER(Name), (
126    fun() ->
127        case config:get(metrics) of
128            ok ->
129                metrics_counter:incr(Name);
130            _ -> ok
131        end
132    end())).
133
134-define(TIMER_APPEND(Name, Timer), (
135    fun() ->
136        case config:get(metrics) of
137            ok ->
138                metrics_gauge:append_timer(Name, Timer);
139            _ -> ok
140        end
141    end())).
142
143-define(GAUGE_APPEND(Gauge, Value), (
144    fun() ->
145        case config:get(metrics) of
146            ok ->
147                metrics_gauge:append(Gauge, Value);
148            _ -> ok
149        end
150    end()
151)).
152
153
154% Backends
155
156-define(PUBSUB_MODULE, mnesia_pubsub).
157-define(AUTH_MODULE(Module),
158        (fun() ->
159                 list_to_atom(Module ++ "_auth")
160         end())).
161-define(DB_MODULE,
162        (fun() ->
163                 list_to_atom(atom_to_list(?MODULE) ++ "_"
164                              ++ atom_to_list(config:get(db)))
165         end())).
166-define(SEARCH_MODULE,
167        (fun() ->
168                 list_to_atom(atom_to_list(?MODULE) ++ "_"
169                              ++ atom_to_list(config:get(search)) ++ "_search")
170         end())).
171
172-define(REMOVE_ID_FROM_RECORD(Params, Record),
173        case Params of
174            Params when is_list(Params) ->
175                lists:map(fun(#Record{id={Id, _Domain}} = Param) ->
176                                  Param#Record{id=Id}
177                          end, Params);
178            Params when is_record(Params, Record) ->
179                {Id, _Domain} = Params#Record.id,
180                Params#Record{id=Id}
181        end).