DviSessionUpnp::DviSessionUpnp(DvStack& aDvStack, TIpAddress aInterface, TUint aPort, IRedirector& aRedirector) : iDvStack(aDvStack) , iInterface(aInterface) , iPort(aPort) , iRedirector(aRedirector) , iShutdownSem("DSUS", 1) { iReadBuffer = new Srs<kMaxRequestBytes>(*this); iReaderRequest = new ReaderHttpRequest(aDvStack.GetStack(), *iReadBuffer); iWriterChunked = new WriterHttpChunked(*this); iWriterBuffer = new Sws<kMaxResponseBytes>(*iWriterChunked); iWriterResponse = new WriterHttpResponse(*iWriterBuffer); iReaderRequest->AddMethod(Http::kMethodGet); iReaderRequest->AddMethod(Http::kMethodPost); iReaderRequest->AddMethod(Http::kMethodHead); iReaderRequest->AddMethod(kUpnpMethodSubscribe); iReaderRequest->AddMethod(kUpnpMethodUnsubscribe); iReaderRequest->AddHeader(iHeaderHost); iReaderRequest->AddHeader(iHeaderContentLength); iReaderRequest->AddHeader(iHeaderConnection); iReaderRequest->AddHeader(iHeaderExpect); iReaderRequest->AddHeader(iHeaderSoapAction); iReaderRequest->AddHeader(iHeaderSid); iReaderRequest->AddHeader(iHeaderTimeout); iReaderRequest->AddHeader(iHeaderNt); iReaderRequest->AddHeader(iHeaderCallback); iReaderRequest->AddHeader(iHeaderAcceptLanguage); iPropertyWriterFactory = new PropertyWriterFactory(iDvStack, aInterface, aPort); }
PropertyWriterUpnp::PropertyWriterUpnp(DvStack& aDvStack, const Endpoint& aPublisher, const Endpoint& aSubscriber, const Brx& aSubscriberPath, const Brx& aSid, TUint aSequenceNumber) : iDvStack(aDvStack) { iSocket.Open(); iSocket.Connect(aSubscriber, aDvStack.GetStack().InitParams().TcpConnectTimeoutMs()); iWriterChunked = new WriterHttpChunked(iSocket); iWriteBuffer = new Sws<kMaxRequestBytes>(*iWriterChunked); iWriterEvent = new WriterHttpRequest(*iWriteBuffer); SetWriter(*iWriteBuffer); iWriterEvent->WriteMethod(kUpnpMethodNotify, aSubscriberPath, Http::eHttp11); IWriterAscii& writer = iWriterEvent->WriteHeaderField(Http::kHeaderHost); Endpoint::EndpointBuf buf; aPublisher.AppendEndpoint(buf); writer.Write(buf); writer.WriteFlush(); iWriterEvent->WriteHeader(Http::kHeaderContentType, Brn("text/xml; charset=\"utf-8\"")); iWriterEvent->WriteHeader(kUpnpHeaderNt, Brn("upnp:event")); iWriterEvent->WriteHeader(kUpnpHeaderNts, Brn("upnp:propchange")); writer = iWriterEvent->WriteHeaderField(HeaderSid::kHeaderSid); writer.Write(HeaderSid::kFieldSidPrefix); writer.Write(aSid); writer.WriteFlush(); iWriterEvent->WriteHeader(Http::kHeaderTransferEncoding, Http::kTransferEncodingChunked); writer = iWriterEvent->WriteHeaderField(kUpnpHeaderSeq); writer.WriteUint(aSequenceNumber); writer.WriteFlush(); iWriterEvent->WriteHeader(Http::kHeaderConnection, Http::kConnectionClose); iWriterEvent->WriteFlush(); iWriterChunked->SetChunked(true); iWriteBuffer->Write(Brn("<?xml version=\"1.0\"?>")); iWriteBuffer->Write(Brn("<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">")); }