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

Contents of /main/sip/resiprocate/X_msMsgsInvite.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1796 - (show annotations) (download)
Tue Sep 16 13:50:58 2003 UTC (16 years, 4 months ago) by fluffy
File size: 4969 byte(s)
fixed up license text

1 #if defined(HAVE_CONFIG_H)
2 #include "resiprocate/config.hxx"
3 #endif
4
5 #include "resiprocate/X_msMsgsInvite.hxx"
6 #include "resiprocate/SipMessage.hxx"
7 #include "resiprocate/os/Logger.hxx"
8
9 using namespace resip;
10 using namespace std;
11
12 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP
13
14 ContentsFactory<X_msMsgsInvite> X_msMsgsInvite::Factory;
15
16 X_msMsgsInvite::X_msMsgsInvite()
17 : Contents(getStaticType()),
18 mPort(0),
19 mHost()
20 {}
21
22 X_msMsgsInvite::X_msMsgsInvite(const Data& txt)
23 : Contents(getStaticType()),
24 mPort(0),
25 mHost()
26 {}
27
28 X_msMsgsInvite::X_msMsgsInvite(HeaderFieldValue* hfv, const Mime& contentsType)
29 : Contents(hfv, contentsType),
30 mPort(0),
31 mHost()
32 {}
33
34 X_msMsgsInvite::X_msMsgsInvite(const Data& txt, const Mime& contentsType)
35 : Contents(contentsType),
36 mPort(0),
37 mHost()
38 {}
39
40 X_msMsgsInvite::X_msMsgsInvite(const X_msMsgsInvite& rhs)
41 : Contents(rhs),
42 mPort(rhs.mPort),
43 mHost(rhs.mHost)
44 {}
45
46 X_msMsgsInvite::~X_msMsgsInvite()
47 {}
48
49 X_msMsgsInvite&
50 X_msMsgsInvite::operator=(const X_msMsgsInvite& rhs)
51 {
52 if (this != &rhs)
53 {
54 Contents::operator=(rhs);
55 mPort = rhs.mPort;
56 mHost = rhs.mHost;
57 }
58 return *this;
59 }
60
61 Contents*
62 X_msMsgsInvite::clone() const
63 {
64 return new X_msMsgsInvite(*this);
65 }
66
67 const Mime&
68 X_msMsgsInvite::getStaticType()
69 {
70 // set charset ?dlb?
71 static Mime type("text","x-msmsgsinvite");
72
73 return type;
74 }
75
76 std::ostream&
77 X_msMsgsInvite::encodeParsed(std::ostream& str) const
78 {
79 for (Attributes::const_iterator i = mAttributes.begin();
80 i != mAttributes.end(); i++)
81 {
82 str << i->first << ": " << i->second << Symbols::CRLF;
83 }
84 if (mPort)
85 {
86 str << "Port: " << mPort << Symbols::CRLF;
87 }
88
89 if (!mHost.empty())
90 {
91 str << "IP-Address: " << mHost << Symbols::CRLF;
92 }
93
94 return str;
95 }
96
97 void
98 X_msMsgsInvite::parse(ParseBuffer& pb)
99 {
100 DebugLog(<< "X_msMsgsInvite::parse: " << pb.position());
101
102 Data attribute;
103 Data value;
104
105 while (!pb.eof())
106 {
107 const char* anchor = pb.skipWhitespace();
108 pb.skipToChar(Symbols::COLON[0]);
109 pb.data(attribute, anchor);
110 pb.skipChar(Symbols::COLON[0]);
111 pb.skipWhitespace();
112
113 if (attribute == "Port")
114 {
115 mPort = pb.integer();
116 }
117 else if (attribute == "IP-Address")
118 {
119 pb.skipToChars(Symbols::CRLF);
120 pb.data(mHost, anchor);
121 }
122 else
123 {
124 pb.skipToChars(Symbols::CRLF);
125 pb.data(value, anchor);
126 mAttributes.push_back(make_pair(attribute, value));
127 }
128 pb.skipWhitespace();
129 }
130 }
131 /* ====================================================================
132 * The Vovida Software License, Version 1.0
133 *
134 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
135 *
136 * Redistribution and use in source and binary forms, with or without
137 * modification, are permitted provided that the following conditions
138 * are met:
139 *
140 * 1. Redistributions of source code must retain the above copyright
141 * notice, this list of conditions and the following disclaimer.
142 *
143 * 2. Redistributions in binary form must reproduce the above copyright
144 * notice, this list of conditions and the following disclaimer in
145 * the documentation and/or other materials provided with the
146 * distribution.
147 *
148 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
149 * and "Vovida Open Communication Application Library (VOCAL)" must
150 * not be used to endorse or promote products derived from this
151 * software without prior written permission. For written
152 * permission, please contact vocal@vovida.org.
153 *
154 * 4. Products derived from this software may not be called "VOCAL", nor
155 * may "VOCAL" appear in their name, without prior written
156 * permission of Vovida Networks, Inc.
157 *
158 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
159 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
160 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
161 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
162 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
163 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
164 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
165 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
166 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
167 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
168 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
169 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
170 * DAMAGE.
171 *
172 * ====================================================================
173 *
174 * This software consists of voluntary contributions made by Vovida
175 * Networks, Inc. and many individuals on behalf of Vovida Networks,
176 * Inc. For more information on Vovida Networks, Inc., please see
177 * <http://www.vovida.org/>.
178 *
179 */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27