Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 327 lines (283 sloc) 13.83 kb
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
1 %%% This code was developped by IDEALX (http://IDEALX.org/) and
2 %%% contributors (their names can be found in the CONTRIBUTORS file).
3 %%% Copyright (C) 2000-2004 IDEALX
4 %%%
5 %%% This program is free software; you can redistribute it and/or modify
6 %%% it under the terms of the GNU General Public License as published by
7 %%% the Free Software Foundation; either version 2 of the License, or
8 %%% (at your option) any later version.
9 %%%
10 %%% This program is distributed in the hope that it will be useful,
11 %%% but WITHOUT ANY WARRANTY; without even the implied warranty of
12 %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 %%% GNU General Public License for more details.
14 %%%
15 %%% You should have received a copy of the GNU General Public License
16 %%% along with this program; if not, write to the Free Software
17 %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
18 %%%
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
19
5d10a86f » nniclausse
2004-08-10 add explicit exception in the GPL for linking EPL modules (obvious, b…
20 %%% In addition, as a special exception, you have the permission to
21 %%% link the code of this program with any library released under
22 %%% the EPL license and distribute linked combinations including
23 %%% the two.
24
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
25 %%% File : ts_jabber.erl
41e965d3 » nniclausse
2005-11-27 update email
26 %%% Author : Nicolas Niclausse <nicolas@niclux.org>
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
27 %%% Purpose : Jabber/XMPP plugin
41e965d3 » nniclausse
2005-11-27 update email
28 %%% Created : 11 Jan 2004 by Nicolas Niclausse <nicolas@niclux.org>
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
29
30 -module(ts_jabber).
31 -author('nniclausse@hyperion').
32
437fa016 » nniclausse
2011-05-03 add ts_plugin behaviour. Fix all plugins (dump and parse_bidi not
33 -behavior(ts_plugin).
34
583ea5e3 » nniclausse
2012-08-22 put macros in a separated header file; add NOW macro
35 -include("ts_macros.hrl").
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
36 -include("ts_profile.hrl").
37 -include("ts_jabber.hrl").
38
27eedec9 » nniclausse
2012-08-24 plugin API change: drop the dyndata field in state_rcv. All the
39 -export([add_dynparams/4,
ddbd1766 » nniclausse
2011-05-09 API change : get_message now has two arguments and returns a tuple {D…
40 get_message/2,
1c1950ad » nniclausse
2006-11-10 first step to support bidirectionnal protocols ( TSUN-27 )
41 session_defaults/0,
32da95d7 » nniclausse
2005-08-19 add dynamic substitution support for jabber (add also data attribute).
42 subst/2,
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
43 parse/2,
a8761b83 » nniclausse
2011-04-12 allow ack=parse for jabber (needs a regexp).
44 dump/2,
1c1950ad » nniclausse
2006-11-10 first step to support bidirectionnal protocols ( TSUN-27 )
45 parse_bidi/2,
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
46 parse_config/2,
96dcaf98 » nniclausse
2010-09-01 API plugin update: add decode_buffer/2 fun. Implemented in http for
47 decode_buffer/2,
3e48368c » nniclausse
2012-08-24 jabber refactoring continuation: fix the bugs (destination was wrong)
48 new_session/0,
49 username/2,
50 userid/1]).
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
51
c3426b5b » cstar
2010-11-25 starttls XMPP support
52 -export ([starttls_bidi/2,
53 presence_bidi/2]).
6322dc6b » nniclausse
2012-09-07 Merge branch 'master' of git.process-one.net:tsung/mainline
54
49399a09 » nniclausse
2004-04-15 ack_type and persistent are now optionnal
55 %%----------------------------------------------------------------------
56 %% Function: session_default/0
1c1950ad » nniclausse
2006-11-10 first step to support bidirectionnal protocols ( TSUN-27 )
57 %% Purpose: default parameters for session (persistent & bidirectional)
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
58 %% Returns: {ok, true|false, true|false}
49399a09 » nniclausse
2004-04-15 ack_type and persistent are now optionnal
59 %%----------------------------------------------------------------------
60 session_defaults() ->
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
61 {ok, true, false}.
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
62
96dcaf98 » nniclausse
2010-09-01 API plugin update: add decode_buffer/2 fun. Implemented in http for
63 %% @spec decode_buffer(Buffer::binary(),Session::record(jabber)) -> NewBuffer::binary()
64 %% @doc We need to decode buffer (remove chunks, decompress ...) for
65 %% matching or dyn_variables
66 %% @end
ebe284ce » nniclausse
2012-08-23 jabber plugin refactoring, first step: use dyndata instead of process…
67 decode_buffer(Buffer,#jabber_session{}) ->
96dcaf98 » nniclausse
2010-09-01 API plugin update: add decode_buffer/2 fun. Implemented in http for
68 Buffer. % nothing to do for jabber
69
3e48368c » nniclausse
2012-08-24 jabber refactoring continuation: fix the bugs (destination was wrong)
70
71
72 %% @spec userid({Session::record(jabber_session),Dynvars:::dynvars()}) -> userid::string()
73 %% @doc return the current userid %% @end
74 userid({#jabber_session{username=UID},_DynVars})-> UID.
75
76
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
77 %%----------------------------------------------------------------------
78 %% Function: new_session/0
79 %% Purpose: initialize session information
80 %% Returns: record or []
81 %%----------------------------------------------------------------------
82 new_session() ->
ebe284ce » nniclausse
2012-08-23 jabber plugin refactoring, first step: use dyndata instead of process…
83 #jabber_session{}.
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
84 %%----------------------------------------------------------------------
85 %% Function: get_message/1
86 %% Purpose: Build a message/request
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
87 %% Args: #jabber
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
88 %% Returns: binary
89 %%----------------------------------------------------------------------
27eedec9 » nniclausse
2012-08-24 plugin API change: drop the dyndata field in state_rcv. All the
90 get_message(Req=#jabber{domain={domain,Domain}}, State=#state_rcv{session=S}) when S#jabber_session.domain == undefined ->
91 NewS = S#jabber_session{domain=Domain, user_server=default},
92 get_message(Req#jabber{domain=Domain, user_server=default},State#state_rcv{session=NewS});
93
94 get_message(Req=#jabber{domain={vhost,FileId}}, State=#state_rcv{session=S}) when S#jabber_session.domain == undefined ->
95 {Domain,UserServer} = choose_domain(FileId),
96 NewS = S#jabber_session{domain=Domain, user_server=UserServer},
97 get_message(Req#jabber{domain=Domain, user_server=UserServer},State#state_rcv{session=NewS});
98
99 get_message(Req=#jabber{id=user_defined, username=User, passwd=Passwd}, State=#state_rcv{session=S}) when S#jabber_session.id == undefined ->
100 NewS = S#jabber_session{id=user_defined,username=User,passwd=Passwd},
101 %% NewDynVars =ts_dynvars:set(xmpp_userid, User, DynData#dyndata.dynvars),
102 %% ?LOGF("Setting up username ~p for ~p~n",[User,ts_dynvars:lookup(tsung_userid,NewDynVars)],?DEB),
103 get_message(Req, State#state_rcv{session=NewS});
104
105 get_message(Req=#jabber{prefix=Prefix, passwd=Passwd}, State=#state_rcv{session=S}) when S#jabber_session.id == undefined ->
106 Id = case ts_user_server:get_idle(S#jabber_session.user_server) of
107 {error, no_free_userid} ->
108 ts_mon:add({ count, error_no_free_userid }),
109 exit(no_free_userid);
110 Val->
111 Val
112 end,
113 {NewUser,NewPasswd} = {username(Prefix,Id), password(Passwd,Id)},
114 %% NewDynVars =ts_dynvars:set(xmpp_userid, NewUser, DynData#dyndata.dynvars),
115 %% ?LOGF("Setting up username ~p for ~p~n",[NewUser,ts_dynvars:lookup(tsung_userid,NewDynVars)],?DEB),
116 NewS = S#jabber_session{id=Id,username=NewUser,passwd=NewPasswd},
117
118 get_message(Req#jabber{username=NewUser,passwd=NewPasswd},State#state_rcv{session=NewS});
119
ddbd1766 » nniclausse
2011-05-09 API change : get_message now has two arguments and returns a tuple {D…
120 get_message(Req=#jabber{},#state_rcv{session=S}) ->
121 {ts_jabber_common:get_message(Req),S}.
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
122
27eedec9 » nniclausse
2012-08-24 plugin API change: drop the dyndata field in state_rcv. All the
123
437fa016 » nniclausse
2011-05-03 add ts_plugin behaviour. Fix all plugins (dump and parse_bidi not
124 dump(A,B) ->
125 ts_plugin:dump(A,B).
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
126
127 %%----------------------------------------------------------------------
38e6b18c » nniclausse
2010-08-27 add new type of request for xmpp: wait for data matching a regexp.
128 %% Function: parse/2
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
129 %% Purpose: Parse the given data and return a new state
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
130 %% Args: Data (binary)
131 %% State (record)
38e6b18c » nniclausse
2010-08-27 add new type of request for xmpp: wait for data matching a regexp.
132 %% Returns: {NewState, Opts, Close}
133 %% State = #state_rcv{}
134 %% Opts = proplist()
135 %% Close = bool()
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
136 %%----------------------------------------------------------------------
38e6b18c » nniclausse
2010-08-27 add new type of request for xmpp: wait for data matching a regexp.
137 parse(closed, State) ->
138 ?LOG("XMPP connection closed by server!",?WARN),
139 {State#state_rcv{ack_done = true}, [], true};
a8761b83 » nniclausse
2011-04-12 allow ack=parse for jabber (needs a regexp).
140 parse(Data, State=#state_rcv{datasize=Size}) ->
38e6b18c » nniclausse
2010-08-27 add new type of request for xmpp: wait for data matching a regexp.
141 ?DebugF("RECEIVED : ~p~n",[Data]),
142 case get(regexp) of
143 undefined ->
144 ?LOG("No regexp defined, skip",?WARN),
145 {State#state_rcv{ack_done=true}, [], false};
146 Regexp ->
147 case re:run(Data, Regexp) of
148 {match,_} ->
149 ?DebugF("XMPP parsing: Match (regexp was ~p)~n",[Regexp]),
a8761b83 » nniclausse
2011-04-12 allow ack=parse for jabber (needs a regexp).
150 {State#state_rcv{ack_done=true, datasize=Size+size(Data)}, [], false};
38e6b18c » nniclausse
2010-08-27 add new type of request for xmpp: wait for data matching a regexp.
151 nomatch ->
a8761b83 » nniclausse
2011-04-12 allow ack=parse for jabber (needs a regexp).
152 {State#state_rcv{ack_done=false,datasize=Size+size(Data)}, [], false}
38e6b18c » nniclausse
2010-08-27 add new type of request for xmpp: wait for data matching a regexp.
153 end
154 end.
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
155
156 %%----------------------------------------------------------------------
157 %% Function: parse_bidi/2
158 %% Purpose: Parse the given data, return a response and new state
159 %% Args: Data (binary)
160 %% State (record)
161 %% Returns: Data (binary)
162 %% NewState (record)
163 %%----------------------------------------------------------------------
c3426b5b » cstar
2010-11-25 starttls XMPP support
164 parse_bidi(Data, State) ->
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
165 RcvdXml = binary_to_list(Data),
6322dc6b » nniclausse
2012-09-07 Merge branch 'master' of git.process-one.net:tsung/mainline
166 BidiElements =
c3426b5b » cstar
2010-11-25 starttls XMPP support
167 [{"<presence[^>]*subscribe[\"\']", presence_bidi},
168 {"<proceed", starttls_bidi}],
169 lists:foldl(fun({Regex, Handler}, Acc)->
6322dc6b » nniclausse
2012-09-07 Merge branch 'master' of git.process-one.net:tsung/mainline
170 case re:run(RcvdXml,Regex) of
600f80e7 » nniclausse
2012-09-07 regexp is gone
171 {match,_} ->
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
172 ?LOGF("RECEIVED : ~p~n",[RcvdXml],?DEB),
c3426b5b » cstar
2010-11-25 starttls XMPP support
173 ?MODULE:Handler(RcvdXml, State);
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
174 _Else ->
c3426b5b » cstar
2010-11-25 starttls XMPP support
175 Acc
176 end
177 end, {nodata, State}, BidiElements).
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
178
c3426b5b » cstar
2010-11-25 starttls XMPP support
179 presence_bidi(RcvdXml, State)->
600f80e7 » nniclausse
2012-09-07 regexp is gone
180 {match,SubMatches} = re:run(RcvdXml,"<presence[^>]*subscribe[\"\'][^>]*>",[global]),
c3426b5b » cstar
2010-11-25 starttls XMPP support
181 bidi_resp(subscribed,RcvdXml,SubMatches,State).
6322dc6b » nniclausse
2012-09-07 Merge branch 'master' of git.process-one.net:tsung/mainline
182
c3426b5b » cstar
2010-11-25 starttls XMPP support
183 starttls_bidi(_RcvdXml, #state_rcv{socket= Socket}=State)->
184 ssl:start(),
185 {ok, SSL} = ts_ssl:connect(Socket, []),
186 ?LOGF("Upgrading to TLS : ~p",[SSL],?INFO),
187 {nodata, State#state_rcv{socket=SSL,protocol=ts_ssl}}.
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
188
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
189 %%----------------------------------------------------------------------
190 %% Function: bidi_resp/4
191 %% Purpose: Parse XMPP packet, build client response
192 %% Accomodates single packets w/ multiple requests
193 %% Args: RcvdXml (list)
194 %% Submatches (list)
195 %% State (record)
196 %% Returns: Data (binary)
197 %% NewState (record)
198 %%----------------------------------------------------------------------
199 %% subscribed: Complete a pending subscription request
200 bidi_resp(subscribed,RcvdXml,SubMatches,State) ->
201 JoinedXml=lists:foldl(fun(X,Foo) ->
d03a2207 » nniclausse
2010-08-18 Merge branch 're'
202 [{Start,Len}]=X,
203 SubStr = string:substr(RcvdXml,Start+1,Len),
ed8bdd8a » Nicolas Niclausse
2010-01-16 use re instead of regexp (TSUN-125)
204 case re:run(SubStr,"from=[\"']([^\s]*)[\"'][\s\/\>]",[{capture,[1],list}]) of
205 {match,[MyId]} ->
206 %% MyId=string:substr(SubStr,Start1 +6, Length1 -8),
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
207 ?LOGF("Subscription request from : ~p~n",[MyId],?DEB),
208 MyXml = ["<presence to='", MyId, "' type='subscribed'/>"],
209 lists:append([Foo],[MyXml]);
210 _Else ->
211 ?LOGF("Error getting sender address: ~p~n",[SubStr],?DEB),
212 ""
213 end
214 end,"",SubMatches),
215 case lists:flatten(JoinedXml) of
216 "" ->
217 {nodata,State};
218 _ ->
219 ?LOGF("RESPONSE TO SEND : ~s~n",[JoinedXml],?DEB),
220 {list_to_binary(JoinedXml),State}
221 end.
1c1950ad » nniclausse
2006-11-10 first step to support bidirectionnal protocols ( TSUN-27 )
222
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
223 %%
224 parse_config(Element, Conf) ->
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
225 ts_config_jabber:parse_config(Element, Conf).
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
226
227 %%----------------------------------------------------------------------
72f77c4e » nniclausse
2004-08-03 fix: add_dynparams func has 4 args now
228 %% Function: add_dynparams/4
8ac455b4 » nniclausse
2004-01-15 -add function for Debug message only (not executed unless compiled wi…
229 %% Purpose: add dynamic parameters to build the message
230 %%----------------------------------------------------------------------
d556325e » Nicolas Niclausse
2010-01-25 update vhost patch against trunk (TSUN-82)
231
232 %% The rest of the code expect to found a "domain" field in the #jabber request
233 %% with the domain of the jabber server (as string). We use the step of dynvars substitution
c7cf8d8e » Nicolas Niclausse
2010-02-05 fix whitespaces + licence header
234 %% to choose and set the domain we want to connect, and keep that choice in the
d556325e » Nicolas Niclausse
2010-01-25 update vhost patch against trunk (TSUN-82)
235 %% process dictionary so we reuse it for all request made from the same session.
236 %% (see comments on choose_domain/1
237 %%
c7cf8d8e » Nicolas Niclausse
2010-02-05 fix whitespaces + licence header
238 %% if we are testing a single domain (the default case), we change from {domain,D}.
d556325e » Nicolas Niclausse
2010-01-25 update vhost patch against trunk (TSUN-82)
239 %% to the specified domain (D). If {vhost,FileId}, we choose a domain from that file
240 %% and set it.
241
27eedec9 » nniclausse
2012-08-24 plugin API change: drop the dyndata field in state_rcv. All the
242 %% first request in a session, do nothing
243 add_dynparams(Subst, {DynVars, S}, Param=#jabber{}, Host) when S#jabber_session.id == undefined ->
244 add_dynparams2(Subst,DynVars, Param, Host);
245
246 add_dynparams(Subst, {DynVars, S}, Param=#jabber{}, Host) ->
247 add_dynparams2(Subst,DynVars, Param#jabber{id=S#jabber_session.id,
248 username=S#jabber_session.username,
249 passwd=S#jabber_session.passwd,
250 domain=S#jabber_session.domain,
251 user_server=S#jabber_session.user_server},Host).
252
253
254 add_dynparams2(false,_, Param, _Host) ->
3834b0b6 » nniclausse
2007-11-12 bidirectional support for xmpp:subscribe messages (Jason Tucker) +
255 Param;
27eedec9 » nniclausse
2012-08-24 plugin API change: drop the dyndata field in state_rcv. All the
256 add_dynparams2(true, DynVars, Param, _Host) ->
32da95d7 » nniclausse
2005-08-19 add dynamic substitution support for jabber (add also data attribute).
257 ?DebugF("Subst in jabber msg (~p) with dyn vars ~p~n",[Param,DynVars]),
27eedec9 » nniclausse
2012-08-24 plugin API change: drop the dyndata field in state_rcv. All the
258 NewParam = subst(Param, DynVars),
259 updatejab(DynVars, NewParam).
d556325e » Nicolas Niclausse
2010-01-25 update vhost patch against trunk (TSUN-82)
260
261
0232848d » Nicolas Niclausse
2010-01-28 fix merge of vhost patch (TSUN-82)
262 %% This isn't ideal.. but currently there is no other way
d556325e » Nicolas Niclausse
2010-01-25 update vhost patch against trunk (TSUN-82)
263 %% than use side effects, as get_message/1 andn add_dynparams/4 aren't allowed
0232848d » Nicolas Niclausse
2010-01-28 fix merge of vhost patch (TSUN-82)
264 %% to return a new DynData, and so they can't modify the session state.
d556325e » Nicolas Niclausse
2010-01-25 update vhost patch against trunk (TSUN-82)
265 choose_domain(VHostFileId) ->
ebe284ce » nniclausse
2012-08-23 jabber plugin refactoring, first step: use dyndata instead of process…
266 {ok,Domain} = ts_file_server:get_random_line(VHostFileId),
267 UserServer = global:whereis_name(list_to_atom("us_"++Domain)),
268 {Domain,UserServer}.
35076ae7 » nniclausse
2004-03-31 - add dynamic request substitution (mickael.remond@erlang-fr)
269
270 %%----------------------------------------------------------------------
32da95d7 » nniclausse
2005-08-19 add dynamic substitution support for jabber (add also data attribute).
271 %% Function: subst/2
272 %% Purpose: Replace on the fly dynamic element
35076ae7 » nniclausse
2004-03-31 - add dynamic request substitution (mickael.remond@erlang-fr)
273 %%----------------------------------------------------------------------
27eedec9 » nniclausse
2012-08-24 plugin API change: drop the dyndata field in state_rcv. All the
274 subst(Req=#jabber{id=user_defined, username=Name,passwd=Pwd, data=Data, resource=Resource}, Dynvars) ->
275 NewUser = ts_search:subst(Name,Dynvars),
276 NewPwd = ts_search:subst(Pwd,Dynvars),
277 NewData = ts_search:subst(Data,Dynvars),
278 subst2(Req#jabber{username=NewUser,passwd=NewPwd,data=NewData,resource=ts_search:subst(Resource,Dynvars)}, Dynvars);
279
280 subst(Req=#jabber{data=Data,resource=Resource}, Dynvars) ->
281 subst2(Req#jabber{data=ts_search:subst(Data,Dynvars),resource=ts_search:subst(Resource,Dynvars)},Dynvars).
282
283
284 subst2(Req=#jabber{type = Type}, Dynvars) when Type == 'muc:chat' ; Type == 'muc:join'; Type == 'muc:nick' ; Type == 'muc:exit' ->
285 Req#jabber{nick = ts_search:subst(Req#jabber.nick, Dynvars),
286 room = ts_search:subst(Req#jabber.room, Dynvars)};
287 subst2(Req=#jabber{type = Type}, Dynvars) when Type == 'pubsub:create' ; Type == 'pubsub:subscribe'; Type == 'pubsub:publish'; Type == 'pubsub:delete' ->
288 Req#jabber{node = ts_search:subst(Req#jabber.node, Dynvars)};
289 subst2(Req=#jabber{type = Type}, Dynvars) when Type == 'pubsub:unsubscribe' ->
290 NewNode=ts_search:subst(Req#jabber.node,Dynvars),
291 NewSubId=ts_search:subst(Req#jabber.subid,Dynvars),
ebe284ce » nniclausse
2012-08-23 jabber plugin refactoring, first step: use dyndata instead of process…
292 Req#jabber{node=NewNode,subid=NewSubId};
27eedec9 » nniclausse
2012-08-24 plugin API change: drop the dyndata field in state_rcv. All the
293 subst2(Req, _Dynvars) ->
ebe284ce » nniclausse
2012-08-23 jabber plugin refactoring, first step: use dyndata instead of process…
294 Req.
29482d40 » nniclausse
2006-04-19 merge sip-digest patch (Jason Tucker)
295
296 %%----------------------------------------------------------------------
297 %% Func: updatejab/2
298 %% takes dyn vars and adds them to jabber record
299 %% 'nonce' used for sip-digest auth
300 %% 'sid' session-id used for digest auth
301 %%----------------------------------------------------------------------
0746417d » nniclausse
2008-06-09 bugfix, dynvars can be undefined
302 updatejab(undefined,Param) -> Param;
29482d40 » nniclausse
2006-04-19 merge sip-digest patch (Jason Tucker)
303 updatejab([],Param) -> Param;
304 updatejab([{nonce, Val}|Rest], Param)->
305 updatejab(Rest, Param#jabber{nonce = Val});
306 updatejab([{sid, Val}|Rest], Param)->
307 updatejab(Rest, Param#jabber{sid = Val});
308 updatejab([_|Rest], Param)->
309 updatejab(Rest, Param).
310
ebe284ce » nniclausse
2012-08-23 jabber plugin refactoring, first step: use dyndata instead of process…
311
312
313 %%%----------------------------------------------------------------------
314 %%% Func: username/2
315 %%% Generate the username given a prefix and id
316 %%%----------------------------------------------------------------------
317 username(Prefix, DestId) when is_integer(DestId)->
318 Prefix ++ integer_to_list(DestId);
319 username(Prefix, DestId) ->
320 Prefix ++ DestId.
321
322 %%%----------------------------------------------------------------------
323 %%% Func: password/1
324 %%% Generate password for a given username
325 %%%----------------------------------------------------------------------
326 password(Prefix,Id) ->
327 username(Prefix,Id).
328
329
Something went wrong with that request. Please try again.