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
00029
00031
00032 #ifdef HAVE_CONFIG_H
00033 #include "autoconfig.h"
00034 #endif
00035
00036 #include "tools.h"
00037 #include "upnp_cm.h"
00038 #include "server.h"
00039 #include "upnp_xml.h"
00040 #include "ixml.h"
00041 #include "storage.h"
00042
00043 using namespace zmm;
00044 using namespace mxml;
00045
00046 void ConnectionManagerService::process_subscription_request(zmm::Ref<SubscriptionRequest> request)
00047 {
00048 int err;
00049 IXML_Document *event = NULL;
00050
00051 Ref<Element> propset, property;
00052
00053 Ref<Array<StringBase> > mimeTypes = Storage::getInstance()->getMimeTypes();
00054 String CSV = mime_types_to_CSV(mimeTypes);
00055
00056
00057 propset = UpnpXML_CreateEventPropertySet();
00058 property = propset->getFirstElementChild();
00059 property->appendTextChild(_("CurrentConnectionIDs"), _("0"));
00060 property->appendTextChild(_("SinkProtocolInfo"), _(""));
00061 property->appendTextChild(_("SourceProtocolInfo"), CSV);
00062
00063 String xml = propset->print();
00064 err = ixmlParseBufferEx(xml.c_str(), &event);
00065 if (err != IXML_SUCCESS)
00066 {
00067 throw UpnpException(UPNP_E_SUBSCRIPTION_FAILED, _("Could not convert property set to ixml"));
00068 }
00069
00070 UpnpAcceptSubscriptionExt(Server::getInstance()->getDeviceHandle(),
00071 ConfigManager::getInstance()->getOption(CFG_SERVER_UDN).c_str(),
00072 serviceID.c_str(), event, request->getSubscriptionID().c_str());
00073
00074 ixmlDocument_free(event);
00075 }
00076
00077 void ConnectionManagerService::subscription_update(String sourceProtocol_CSV)
00078 {
00079 int err;
00080 IXML_Document *event = NULL;
00081
00082 Ref<Element> propset, property;
00083
00084 propset = UpnpXML_CreateEventPropertySet();
00085 property = propset->getFirstElementChild();
00086 property->appendTextChild(_("SourceProtocolInfo"), sourceProtocol_CSV);
00087
00088 String xml = propset->print();
00089
00090 err = ixmlParseBufferEx(xml.c_str(), &event);
00091 if (err != IXML_SUCCESS)
00092 {
00094 throw UpnpException(UPNP_E_SUBSCRIPTION_FAILED, _("Could not convert property set to ixml"));
00095
00096 }
00097
00098 UpnpNotifyExt(Server::getInstance()->getDeviceHandle(),
00099 ConfigManager::getInstance()->getOption(CFG_SERVER_UDN).c_str(),
00100 serviceID.c_str(), event);
00101
00102 ixmlDocument_free(event);
00103 }