|
reSIProcate/stack
9694
|
00001 #if defined(HAVE_CONFIG_H) 00002 #include "config.h" 00003 #endif 00004 00005 #include "resip/stack/PlainContents.hxx" 00006 #include "resip/stack/SipMessage.hxx" 00007 #include "rutil/Logger.hxx" 00008 #include "rutil/ParseBuffer.hxx" 00009 #include "rutil/WinLeakCheck.hxx" 00010 00011 using namespace resip; 00012 using namespace std; 00013 00014 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP 00015 00016 const PlainContents PlainContents::Empty; 00017 static bool invokePlainContentsInit = PlainContents::init(); 00018 00019 00020 bool 00021 PlainContents::init() 00022 { 00023 static ContentsFactory<PlainContents> factory; 00024 (void)factory; 00025 return true; 00026 } 00027 00028 00029 PlainContents::PlainContents() 00030 : Contents(getStaticType()), 00031 mText() 00032 {} 00033 00034 PlainContents::PlainContents(const Data& txt) 00035 : Contents(getStaticType()), 00036 mText(txt) 00037 {} 00038 00039 PlainContents::PlainContents(const HeaderFieldValue& hfv, const Mime& contentsType) 00040 : Contents(hfv, contentsType), 00041 mText() 00042 { 00043 } 00044 00045 PlainContents::PlainContents(const Data& txt, const Mime& contentsType) 00046 : Contents(contentsType), 00047 mText(txt) 00048 { 00049 } 00050 00051 PlainContents::PlainContents(const PlainContents& rhs) 00052 : Contents(rhs), 00053 mText(rhs.mText) 00054 { 00055 } 00056 00057 PlainContents::~PlainContents() 00058 { 00059 } 00060 00061 PlainContents& 00062 PlainContents::operator=(const PlainContents& rhs) 00063 { 00064 if (this != &rhs) 00065 { 00066 Contents::operator=(rhs); 00067 mText = rhs.mText; 00068 } 00069 return *this; 00070 } 00071 00072 Contents* 00073 PlainContents::clone() const 00074 { 00075 return new PlainContents(*this); 00076 } 00077 00078 const Mime& 00079 PlainContents::getStaticType() 00080 { 00081 static Mime type("text","plain"); 00082 return type; 00083 } 00084 00085 EncodeStream& 00086 PlainContents::encodeParsed(EncodeStream& str) const 00087 { 00088 //DebugLog(<< "PlainContents::encodeParsed " << mText); 00089 str << mText; 00090 return str; 00091 } 00092 00093 void 00094 PlainContents::parse(ParseBuffer& pb) 00095 { 00096 //DebugLog(<< "PlainContents::parse: " << pb.position()); 00097 00098 const char* anchor = pb.position(); 00099 pb.skipToEnd(); 00100 pb.data(mText, anchor); 00101 00102 //DebugLog("PlainContents::parsed <" << mText << ">" ); 00103 } 00104 00105 00106 /* ==================================================================== 00107 * The Vovida Software License, Version 1.0 00108 * 00109 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00110 * 00111 * Redistribution and use in source and binary forms, with or without 00112 * modification, are permitted provided that the following conditions 00113 * are met: 00114 * 00115 * 1. Redistributions of source code must retain the above copyright 00116 * notice, this list of conditions and the following disclaimer. 00117 * 00118 * 2. Redistributions in binary form must reproduce the above copyright 00119 * notice, this list of conditions and the following disclaimer in 00120 * the documentation and/or other materials provided with the 00121 * distribution. 00122 * 00123 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00124 * and "Vovida Open Communication Application Library (VOCAL)" must 00125 * not be used to endorse or promote products derived from this 00126 * software without prior written permission. For written 00127 * permission, please contact vocal@vovida.org. 00128 * 00129 * 4. Products derived from this software may not be called "VOCAL", nor 00130 * may "VOCAL" appear in their name, without prior written 00131 * permission of Vovida Networks, Inc. 00132 * 00133 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00134 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00135 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00136 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00137 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00138 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00139 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00140 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00141 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00142 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00144 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00145 * DAMAGE. 00146 * 00147 * ==================================================================== 00148 * 00149 * This software consists of voluntary contributions made by Vovida 00150 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00151 * Inc. For more information on Vovida Networks, Inc., please see 00152 * <http://www.vovida.org/>. 00153 * 00154 */
1.7.5.1