00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "brisadevicexmlhandler.h"
00029 #include "brisadevice.h"
00030
00031 #include <QDebug>
00032
00033 using namespace BrisaUpnp;
00034
00035 void BrisaDeviceXMLHandler::xmlGenerator(BrisaDevice *device, QFile *file) {
00036 file->open(QIODevice::ReadWrite | QIODevice::Text);
00037
00038 this->writer = new QXmlStreamWriter(file);
00039 this->writer->setAutoFormatting(true);
00040
00041 this->writer->writeStartDocument();
00042
00043 this->writer->writeStartElement("root");
00044 this->writer->writeAttribute("xmlns", "urn:schemas-upnp-org:device-1-0");
00045
00046 this->writer->writeStartElement("specVersion");
00047 this->writer->writeTextElement("major", device->getAttribute(
00048 BrisaDevice::Major));
00049 this->writer->writeTextElement("minor", device->getAttribute(
00050 BrisaDevice::Minor));
00051 this->writer->writeEndElement();
00052
00053 this->writer->writeTextElement("URLBase", device->getAttribute(
00054 BrisaDevice::UrlBase));
00055 this->writeDevice(device);
00056 this->writer->writeEndElement();
00057
00058 this->writer->writeEndDocument();
00059
00060 file->close();
00061 delete this->writer;
00062 }
00063
00064 void BrisaDeviceXMLHandler::writeDevice(BrisaDevice *device) {
00065 this->writer->writeStartElement("device");
00066 this->writer->writeTextElement("deviceType", device->getAttribute(
00067 BrisaDevice::DeviceType));
00068 this->writer->writeTextElement("friendlyName", device->getAttribute(
00069 BrisaDevice::FriendlyName));
00070 this->writer->writeTextElement("manufacturer", device->getAttribute(
00071 BrisaDevice::Manufacturer));
00072 this->writer->writeTextElement("manufacturerURL", device->getAttribute(
00073 BrisaDevice::ManufacturerUrl));
00074 this->writer->writeTextElement("modelDescription", device->getAttribute(
00075 BrisaDevice::ModelDescription));
00076 this->writer->writeTextElement("modelName", device->getAttribute(
00077 BrisaDevice::ModelName));
00078 this->writer->writeTextElement("modelNumber", device->getAttribute(
00079 BrisaDevice::ModelNumber));
00080 this->writer->writeTextElement("modelURL", device->getAttribute(
00081 BrisaDevice::ModelUrl));
00082 this->writer->writeTextElement("serialNumber", device->getAttribute(
00083 BrisaDevice::SerialNumber));
00084 this->writer->writeTextElement("UDN",
00085 device->getAttribute(BrisaDevice::Udn));
00086 this->writer->writeTextElement("UPC",
00087 device->getAttribute(BrisaDevice::Upc));
00088 this->writer->writeStartElement("iconList");
00089 QList<BrisaIcon> iconList = device->getIconList();
00090 foreach(BrisaIcon i, iconList)
00091 {
00092 this->writer->writeStartElement("icon");
00093 this->writer->writeTextElement("mimetype", i.getAttribute(
00094 BrisaIcon::Mimetype));
00095 this->writer->writeTextElement("width", i.getAttribute(
00096 BrisaIcon::Width));
00097 this->writer->writeTextElement("height", i.getAttribute(
00098 BrisaIcon::Height));
00099 this->writer->writeTextElement("depth", i.getAttribute(
00100 BrisaIcon::Depth));
00101 this->writer->writeTextElement("url",
00102 i.getAttribute(BrisaIcon::Url));
00103 this->writer->writeEndElement();
00104 }
00105 this->writer->writeEndElement();
00106
00107 this->writer->writeStartElement("serviceList");
00108 QList<BrisaService*> serviceList = device->getServiceList();
00109 foreach(BrisaService *s, serviceList)
00110 {
00111 this->writer->writeStartElement("service");
00112 this->writer->writeTextElement("serviceType", s->getAttribute(
00113 BrisaService::ServiceType));
00114 this->writer->writeTextElement("serviceId", s->getAttribute(
00115 BrisaService::ServiceId));
00116 this->writer->writeTextElement("SCPDURL", s->getAttribute(
00117 BrisaService::ScpdUrl));
00118 this->writer->writeTextElement("controlURL", s->getAttribute(
00119 BrisaService::ControlUrl));
00120 this->writer->writeTextElement("eventSubURL", s->getAttribute(
00121 BrisaService::EventSubUrl));
00122 this->writer->writeEndElement();
00123 }
00124 this->writer->writeEndElement();
00125
00126 this->writer->writeStartElement("deviceList");
00127 QList<BrisaDevice*> embeddedDeviceList = device->getEmbeddedDeviceList();
00128 foreach(BrisaDevice *d, embeddedDeviceList)
00129 {
00130 writeDevice(d);
00131 }
00132 this->writer->writeEndElement();
00133
00134 this->writer->writeTextElement("presentationURL", device->getAttribute(
00135 BrisaDevice::PresentationUrl));
00136
00137 this->writer->writeEndElement();
00138 }
00139