⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testmultipartrelated.cxx

📁 这是国外的resip协议栈
💻 CXX
📖 第 1 页 / 共 2 页
字号:
#include <iostream>#include <memory>#include "resip/stack/MultipartMixedContents.hxx"#include "resip/stack/MultipartRelatedContents.hxx"#include "resip/stack/GenericContents.hxx"#include "resip/stack/Rlmi.hxx"#include "resip/stack/Pidf.hxx"#include "resip/stack/Pkcs7Contents.hxx"#include "resip/stack/MultipartSignedContents.hxx"#include "resip/stack/SipMessage.hxx"#include "resip/stack/test/TestSupport.hxx"#include "rutil/ParseBuffer.hxx"using namespace resip;using namespace std;void indent(int indent){   for (int i = 0; i < 3*indent; ++i)   {      cerr << " ";   }}voidtraverseMulti(const MultipartMixedContents* mp,              int level = 0){      for (MultipartRelatedContents::Parts::const_iterator i = mp->parts().begin();           i != mp->parts().end(); ++i)      {         GenericContents* generic;         Pidf* pidf;         Rlmi* rlmi;         MultipartSignedContents* mps;         MultipartMixedContents* mpm;         Pkcs7Contents* pkcs7;         if ((pidf = dynamic_cast<Pidf*>(*i)))         {            indent(level);            cerr << "discovered a Pidf" << endl;         }          else if ((rlmi = dynamic_cast<Rlmi*>(*i)))         {            indent(level);            cerr << "discovered a Rlmi" << endl;         }         else if ((pkcs7 = dynamic_cast<Pkcs7Contents*>(*i)))         {            indent(level);            cerr << "discovered a Pkcs7Contents" << endl;         }         else if ((mps = dynamic_cast<MultipartSignedContents*>(*i)))         {            indent(level);            cerr << "discovered a multipart signed with " << mps->parts().size() << " parts " << endl;            traverseMulti(mps, level+1);         }         else if ((mpm = dynamic_cast<MultipartMixedContents*>(*i)))         {            indent(level);            cerr << "discovered a multipart with " << mpm->parts().size() << " parts " << endl;            traverseMulti(mpm, level+1);         }         else if ((generic = dynamic_cast<GenericContents*>(*i)))         {            indent(level);            cerr << "discovered an unknown type " << generic->getType() << endl;         }         else          {            indent(level);            cerr << "Some other kind of content!" << endl;         }      }}// http://www.softarmor.com/simple/drafts/draft-ietf-simple-event-list-04.txtintmain(){   {      const Data tx0("NOTIFY sip:terminal.example.com SIP/2.0\r\n"                     "Via: SIP/2.0/TCP pres.example.com;branch=z9hG4bKMgRenTETmm\r\n"                     "Max-Forwards: 70\r\n"                     "From: <sip:adam-buddies@pres.example.com>;tag=zpNctbZq\r\n"                     "To: <sip:adam@example.com>;tag=ie4hbb8t\r\n"                     "Call-ID: cdB34qLToC@terminal.example.com\r\n"                     "CSeq: 997935768 NOTIFY\r\n"                     "Contact: <sip:pres.example.com>\r\n"                     "Event: presence\r\n"                     "Subscription-State: active;expires=7200\r\n"                     "Require: eventlist\r\n"                     "Content-Type: multipart/related;type=\"application/rlmi+xml\";\r\n"                     "    start=\"<nXYxAE@pres.example.com>\";boundary=\"50UBfW7LSCVLtggUPe5z\"\r\n"                     "Content-Length: 1560\r\n"                     "\r\n"                     "--50UBfW7LSCVLtggUPe5z\r\n"                     "Content-Transfer-Encoding: binary\r\n"                     "Content-ID: <nXYxAE@pres.example.com>\r\n"                     "Content-Type: application/rlmi+xml;charset=\"UTF-8\"\r\n"                     "\r\n"                     "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"                     "<list xmlns=\"urn:ietf:params:xml:ns:rmli\"\r\n"                     "      uri=\"sip:adam-friends@pres.example.com\" version=\"1\"\r\n"                     "      name=\"Buddy List at COM\" fullState=\"true\">\r\n"                     "  <resource uri=\"sip:bob@example.com\" name=\"Bob Smith\">\r\n"                     "    <instance id=\"juwigmtboe\" state=\"active\"\r\n"                     "              cid=\"bUZBsM@pres.example.com\"/>\r\n"                     "  </resource>\r\n"                     "  <resource uri=\"sip:dave@example.com\" name=\"Dave Jones\">\r\n"                     "    <instance id=\"hqzsuxtfyq\" state=\"active\"\r\n"                     "              cid=\"ZvSvkz@pres.example.com\"/>\r\n"                     "  </resource>\r\n"                     "  <resource uri=\"sip:ed@example.net\" name=\"Ed at NET\" />\r\n"                     "  <resource uri=\"sip:adam-friends@example.org\"\r\n"                     "            name=\"My Friends at ORG\" />\r\n"                     "</list>\r\n"                     "\r\n"                     "--50UBfW7LSCVLtggUPe5z\r\n"                     "Content-Transfer-Encoding: binary\r\n"                     "Content-ID: <bUZBsM@pres.example.com>\r\n"                     "Content-Type: application/pidf+xml;charset=\"UTF-8\"\r\n"                     "\r\n"                     "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"                     "<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\r\n"                     "    entity=\"sip:bob@example.com\">\r\n"                     "  <tuple id=\"sg89ae\">\r\n"                     "    <status>\r\n"                     "      <basic>open</basic>\r\n"                     "    </status>\r\n"                     "    <contact priority=\"1.0\">sip:bob@example.com</contact>\r\n"                     "  </tuple>\r\n"                     "</presence>\r\n"                     "\r\n"                     "--50UBfW7LSCVLtggUPe5z\r\n"                     "Content-Transfer-Encoding: binary\r\n"                     "Content-ID: <ZvSvkz@pres.example.com>\r\n"                     "Content-Type: application/pidf+xml;charset=\"UTF-8\"\r\n"                     "\r\n"                     "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"                     "<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\r\n"                     "    entity=\"sip:dave@example.com\">\r\n"                     "  <tuple id=\"slie74\">\r\n"                     "    <status>\r\n"                     "      <basic>closed</basic>\r\n"                     "    </status>\r\n"                     "  </tuple>\r\n"                     "</presence>\r\n"                     "\r\n"                     "--50UBfW7LSCVLtggUPe5z--\r\n");      const Data txt("NOTIFY sip:terminal.example.com SIP/2.0\r\n"                     "Via: SIP/2.0/TCP pres.example.com;branch=z9hG4bK4EPlfSFQK1\r\n"                     "Max-Forwards: 70\r\n"                     "From: <sip:adam-buddies@pres.example.com>;tag=zpNctbZq\r\n"                     "To: <sip:adam@example.com>;tag=ie4hbb8t\r\n"                     "Call-ID: cdB34qLToC@terminal.example.com\r\n"                     "CSeq: 997935769 NOTIFY\r\n"                     "Contact: <sip:pres.example.com>\r\n"                     "Event: presence\r\n"                     "Subscription-State: active;expires=7200\r\n"                     "Require: eventlist\r\n"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -