/[resiprocate]/main/sip/resiprocate/TransactionUser.cxx
ViewVC logotype

Annotation of /main/sip/resiprocate/TransactionUser.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4390 - (hide annotations) (download)
Mon Apr 18 20:10:16 2005 UTC (14 years, 9 months ago) by sgodin
File size: 4603 byte(s)
added WinLeakCheck to some files
1 jason 4335 #include "resiprocate/TransactionUser.hxx"
2     #include "resiprocate/MessageFilterRule.hxx"
3     #include "resiprocate/os/Logger.hxx"
4 sgodin 4390 #include "resiprocate/os/WinLeakCheck.hxx"
5 jason 4145
6 jason 4335 #define RESIPROCATE_SUBSYSTEM resip::Subsystem::TRANSACTION
7    
8 jason 4147 using namespace resip;
9    
10 jason 4376 TransactionUser::TransactionUser()
11     : mFifo(0, 0)
12 jason 4145 {
13 jason 4335 // This creates a default message filter rule, which
14     // handles all sip: and sips: requests.
15     mRuleList.push_back(MessageFilterRule());
16 jason 4145 }
17    
18 jason 4335 TransactionUser::TransactionUser(MessageFilterRuleList &mfrl)
19 jason 4376 : mFifo(0, 0),
20     mRuleList(mfrl)
21 jason 4335 {
22     }
23    
24 jason 4145 TransactionUser::~TransactionUser()
25     {
26     }
27    
28     void
29 derek 4171 TransactionUser::post(Message* msg)
30     {
31     mFifo.add(msg, TimeLimitFifo<Message>::InternalElement);
32     }
33    
34     void
35 jason 4145 TransactionUser::postToTransactionUser(Message* msg, TimeLimitFifo<Message>::DepthUsage usage)
36     {
37     mFifo.add(msg, usage);
38 jason 4335 //DebugLog (<< "TransactionUser::postToTransactionUser " << msg->brief() << " &=" << &mFifo << " size=" << mFifo.size());
39 jason 4145 }
40    
41 jason 4147 unsigned int
42     TransactionUser::size() const
43 jason 4145 {
44     return mFifo.size();
45     }
46    
47     bool
48     TransactionUser::wouldAccept(TimeLimitFifo<Message>::DepthUsage usage) const
49     {
50     return mFifo.wouldAccept(usage);
51     }
52    
53 jason 4335 bool
54     TransactionUser::isForMe(const SipMessage& msg) const
55     {
56     DebugLog (<< "Checking if " << msg.brief() << " is for me");
57     // do this for each MessageFilterRule
58     for (MessageFilterRuleList::const_iterator i = mRuleList.begin() ;
59     i != mRuleList.end() ; ++i)
60     {
61     DebugLog (<< "Checking rule...");
62     if (i->matches(msg))
63     {
64     DebugLog (<< "Match!");
65     return true;
66     }
67     }
68     DebugLog (<< "No matching rule found");
69     return false;
70     }
71    
72     bool
73     TransactionUser::isMyDomain(const Data& domain) const
74     {
75 sgodin 4390 return mDomainList.count(domain) > 0;
76 jason 4335 }
77    
78     void TransactionUser::addDomain(const Data& domain)
79     {
80 jason 4376 mDomainList.insert(domain);
81 jason 4335 }
82    
83     std::ostream&
84     TransactionUser::encode(std::ostream& strm) const
85     {
86     strm << "TU: " << name() << " size=" << mFifo.size();
87     return strm;
88     }
89    
90     void
91     TransactionUser::setMessageFilterRuleList(MessageFilterRuleList &rules)
92     {
93     mRuleList = rules;
94     }
95    
96     std::ostream&
97     resip::operator<<(std::ostream& strm, const resip::TransactionUser& tu)
98     {
99     tu.encode(strm);
100     return strm;
101     }
102    
103     /* ====================================================================
104     * The Vovida Software License, Version 1.0
105     *
106     * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
107     *
108     * Redistribution and use in source and binary forms, with or without
109     * modification, are permitted provided that the following conditions
110     * are met:
111     *
112     * 1. Redistributions of source code must retain the above copyright
113     * notice, this list of conditions and the following disclaimer.
114     *
115     * 2. Redistributions in binary form must reproduce the above copyright
116     * notice, this list of conditions and the following disclaimer in
117     * the documentation and/or other materials provided with the
118     * distribution.
119     *
120     * 3. The names "VOCAL", "Vovida Open Communication Application Library",
121     * and "Vovida Open Communication Application Library (VOCAL)" must
122     * not be used to endorse or promote products derived from this
123     * software without prior written permission. For written
124     * permission, please contact vocal@vovida.org.
125     *
126     * 4. Products derived from this software may not be called "VOCAL", nor
127     * may "VOCAL" appear in their name, without prior written
128     * permission of Vovida Networks, Inc.
129     *
130     * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
131     * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
132     * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
133     * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
134     * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
135     * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
136     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
137     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
138     * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
139     * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
140     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
141     * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
142     * DAMAGE.
143     *
144     * ====================================================================
145     *
146     * This software consists of voluntary contributions made by Vovida
147     * Networks, Inc. and many individuals on behalf of Vovida Networks,
148     * Inc. For more information on Vovida Networks, Inc., please see
149     * <http://www.vovida.org/>.
150     *
151     */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27