~ubuntu-branches/ubuntu/utopic/ejabberd/utopic

« back to all changes in this revision

Viewing changes to src/ejabberd_local.erl

  • Committer: Package Import Robot
  • Author(s): Gerfried Fuchs, Konstantin Khomoutov, Gerfried Fuchs
  • Date: 2011-09-11 16:16:55 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: package-import@ubuntu.com-20110911161655-rz3jall453jo3zek
Tags: 2.1.8-1
[ Konstantin Khomoutov ]
* New upstream release.
* Remove patch fixing DSA-2248-1 (CVE-2011-1753)
  as the fix is now integrated upstream.
* Drop patches from OLPC project implementing @recent@ and @online@
  shared roster groups; support for @online@ is now intergated upstream.
* Add patch fixing version string where applicable (EJAB-1484).
* Bump standards version to 3.9.2

[ Gerfried Fuchs ]
* Add recommended targets build-arch and build-indep to debian/rules.
* Fix spelling error in manpage noticed by lintian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
%%% Created : 30 Nov 2002 by Alexey Shchepin <alexey@process-one.net>
6
6
%%%
7
7
%%%
8
 
%%% ejabberd, Copyright (C) 2002-2010   ProcessOne
 
8
%%% ejabberd, Copyright (C) 2002-2011   ProcessOne
9
9
%%%
10
10
%%% This program is free software; you can redistribute it and/or
11
11
%%% modify it under the terms of the GNU General Public License as
34
34
 
35
35
-export([route/3,
36
36
         route_iq/4,
 
37
         route_iq/5,
37
38
         process_iq_reply/3,
38
39
         register_iq_handler/4,
39
40
         register_iq_handler/5,
40
41
         register_iq_response_handler/4,
 
42
         register_iq_response_handler/5,
41
43
         unregister_iq_handler/2,
42
44
         unregister_iq_response_handler/2,
43
45
         refresh_iq_handlers/0,
123
125
            ok
124
126
    end.
125
127
 
126
 
route_iq(From, To, #iq{type = Type} = IQ, F) when is_function(F) ->
 
128
route_iq(From, To, IQ, F) ->
 
129
    route_iq(From, To, IQ, F, undefined).
 
130
 
 
131
route_iq(From, To, #iq{type = Type} = IQ, F, Timeout) when is_function(F) ->
127
132
    Packet = if Type == set; Type == get ->
128
133
                     ID = randoms:get_string(),
129
134
                     Host = From#jid.lserver,
130
 
                     register_iq_response_handler(Host, ID, undefined, F),
 
135
                     register_iq_response_handler(Host, ID, undefined, F, Timeout),
131
136
                     jlib:iq_to_xml(IQ#iq{id = ID});
132
137
                true ->
133
138
                     jlib:iq_to_xml(IQ)
134
139
             end,
135
140
    ejabberd_router:route(From, To, Packet).
136
141
 
137
 
register_iq_response_handler(_Host, ID, Module, Function) ->
138
 
    TRef = erlang:start_timer(?IQ_TIMEOUT, ejabberd_local, ID),
 
142
register_iq_response_handler(Host, ID, Module, Function) ->
 
143
    register_iq_response_handler(Host, ID, Module, Function, undefined).
 
144
 
 
145
register_iq_response_handler(_Host, ID, Module, Function, Timeout0) ->
 
146
    Timeout = case Timeout0 of
 
147
                  undefined ->
 
148
                      ?IQ_TIMEOUT;
 
149
                  N when is_integer(N), N > 0 ->
 
150
                      N
 
151
              end,
 
152
    TRef = erlang:start_timer(Timeout, ejabberd_local, ID),
139
153
    mnesia:dirty_write(#iq_response{id = ID,
140
154
                                    module = Module,
141
155
                                    function = Function,