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